I have a ggplot with points on it. I want to group these points into group based on their location, but I want to do it interactively with the "lasso" tool in plotly.
I can't figure out how to save the info from the group I've lassoed. I basically want to add a column in my df for "group" then pick group 1 with a lasso, group 2 with a lasso, etc.
I have figured out how to plot it and lasso points, but I want to say
df$group[df____lasso choose___] <- 1
I figure there must be a way.
set.seed(1)
df <- data.frame(matrix(nrow=300,ncol=3))
colnames(df) <- c("X","Y","Group")
df[,1:2] <- runif(600,0,200)
library(ggplot2)
library(plotly)
p <- ggplot(df,aes(x=X,y=Y))+
geom_point()
ggplotly(p)