Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 运行ggplotly函数会导致FUN(X[[i]],…):object';x';找不到_R_Ggplot2_Plotly_Ggplotly - Fatal编程技术网

R 运行ggplotly函数会导致FUN(X[[i]],…):object';x';找不到

R 运行ggplotly函数会导致FUN(X[[i]],…):object';x';找不到,r,ggplot2,plotly,ggplotly,R,Ggplot2,Plotly,Ggplotly,今天我试着运行以前运行得很好的代码。但我犯了以下错误: > 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()`

今天我试着运行以前运行得很好的代码。但我犯了以下错误:

> 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
>p1-ggplotly(p1)
我们建议您将ggplot2的开发版本与`ggplotly()一起使用`
使用以下命令安装它:`devtools::Install_github('hadley/ggplot2'))`
FUN(X[[i]],…)中出错:找不到对象“X”
我的数据集如下所示:

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)

seq在创建
p1
时,您试图使用变量名
x
作为x轴。错误告诉您在数据帧中找不到对象
x
。事实上,在创建
dframe
时,没有将任何列命名为
x
,因此这是意料之中的

试着用
label
代替
text
我试过
text
label
key
过去都有效,但现在都返回相同的错误。你把
x
y
映射到
dframe
变量了吗?哦,真是个愚蠢的错误,非常感谢。我不得不以某种方式破坏数据集,请将其作为答案发布,以便我可以接受它。