I am trying to change the data displayed in a scatterplot using a dropdown event. I am using R in RStudio on Windows 7. The data are not important at this point and are merely placeholders for more complex changes…
# read in master file dataset
df <- read.csv('master_file_dataset.csv')
data <- df[1:1000,]
data2 <- df[1:100,]
# test plotly
p <- plot_ly(data = data, type = 'scatter', mode = 'markers',
x = ~Age, y = ~Ending.Compensation, visible=F) %>%
add_trace(data = data2, x = ~Age, y = ~Ending.Compensation, visible=F) %<%
add_markers(marker = list(line = list(color = "black", width = 1))) %>%
layout(
title = "cluster selector example",
xaxis = list(title = 'Age'),
yaxis = list(title = "Salary"),
updatemenus = list(
list(
yanchor = 'auto',
buttons = list(
list(method = "update",
args = list("visible", list(TRUE, FALSE)),
label = 'data'),
list(method = "update",
args = list("visible", list(TRUE, FALSE)),
label = 'data2')
))))
I get this error…
Error in eval(expr, envir, enclos) : could not find function "%<%"
I am not sure how to get past this error and ultimately how to change the data using the dropdown event. Thanks for your help
Ben