错误:(从警告转换)忽略未知美学(Error: (converted from warning) I

2019-10-29 13:20发布

有时,当我使用ggplot2我收到以下错误:

> dframe <- data.frame(a=letters, b=LETTERS, x=runif(26), y=runif(26))
> p <- ggplot(dframe, aes(x,y)) + geom_point(aes(text=sprintf("letter: %s<br>LETTER: %s", a, b)))
Error: (converted from warning) Ignoring unknown aesthetics: text

然后我重新启动的R-Studio,一切工作正常(直到问题再次发生)(当你有你的工作没有完成,这是非常艰巨的):

> dframe <- data.frame(a=letters, b=LETTERS, x=runif(26), y=runif(26))
> p <- ggplot(dframe, aes(x,y)) + geom_point(aes(text=sprintf("letter: %s<br>LETTER: %s", a, b)))
Warning: Ignoring unknown aesthetics: text
> ggplotly(p)
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`

问题是什么? 我使用的是Windows 10,R-工作室1.0.153,以及下述R版本:

> R.version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          4.2                         
year           2017                        
month          09                          
day            28                          
svn rev        73368                       
language       R                           
version.string R version 3.4.2 (2017-09-28)
nickname       Short Summer           

相应的软件包版本如下:

ggplot2 2.2.1
plotly  4.7.1

谢谢

Answer 1:

下发生的审美映射ggplot而不是geom_point ,以避免该警告:

## This produces an "unknown aesthetic" warning
ggplot( mtcars, aes( x = wt, y = mpg ) ) + geom_point( aes( text = cyl ) )

## This doesn't
ggplot( mtcars, aes( x = wt, y = mpg, text = cyl ) ) + geom_point()


文章来源: Error: (converted from warning) Ignoring unknown aesthetics
标签: r ggplot2