错误:(从警告转换)忽略未知的美学 [英] Error: (converted from warning) Ignoring unknown aesthetics

查看:867
本文介绍了错误:(从警告转换)忽略未知的美学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时当我使用 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)))
错误: (从警告转换)忽略未知美学: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)))
警告:忽略未知的美学:text
> ggplotly(p)
我们建议您使用`ggplotly()`
的ggplot2的开发版本,使用:devtools :: install_github('hadley / ggplot2')`

有什么问题?我使用的是Windows 10,R-studio 1.0.153和R版本: R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
系统x86_64,mingw32
status
major 3
次要4.2
2017年
月份09
日期28
svn转换73368
语言R
version.string R版本3.4.2(2017 -09-28)
绰号短夏季

相应的套餐包括以下版本:

  ggplot2 2.2.1 
plotly 4.7.1

感谢

解决方案

ggplot 下面而不是 geom_point 以避免警告:

  ##这会产生一个未知美学警告
ggplot(mtcars,aes(x = wt,y = mpg))+ geom_point(aes(text = cyl))

##这不是
ggplot(mtcars,aes(x = wt,y = mpg,text = cyl))+ geom_point()


Sometimes when I use ggplot2 I get following error:

> 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

Then I restart R-Studio (which is pretty daunting when you have your work unfinished) and everything works fine (until the problem happens again):

> 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')`

What is the problem? I'm using Windows 10, R-studio 1.0.153, and following R version:

> 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           

Corresponding packages are following version:

ggplot2 2.2.1
plotly  4.7.1

Thanks

解决方案

Place the aesthetic mapping under ggplot instead of geom_point to avoid the warning:

## 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()

这篇关于错误:(从警告转换)忽略未知的美学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆