Today I was trying to run code which previously worked fine. But I got following error:
> p1 <- ggplot(dframe, aes(x, y, text=sprintf("letter: %s<br>LETTER: %s<br>", a, b))) + geom_line() + geom_point()
> ggplotly(p1)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
Error in FUN(X[[i]], ...) : object 'x' not found
My dataset looks like this:
seq <- 1:10
name <- c(paste0("company",1:10))
value <- c(250,125,50,40,40,30,20,20,10,10)
lett <- letters[1:10]
dframe <- data.frame(seq,name,value,lett)
My environment:
why this happens? Thanks
In the creation of p1
you're trying to use the variable name x
as the x axis. The error is telling you that it can't find the object x
in your data frame. Indeed, when you're creating dframe
, you're not naming any column as x
, so that is to be expected.