向量,ggplot2不知道如何处理类数字的数据 [英] Vector, ggplot2 doesn't know how to deal with data of class numeric
本文介绍了向量,ggplot2不知道如何处理类数字的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误:ggplot2不知道如何处理类数字的数据。
这是什么意思?
代码:
vector1 < - c(x1,x2 ,x3,...)
库(ggplot2)
ggplot(vector1,aes(x = x,y = value))+ boxplot()
解决方案
您可以按如下方式使用 qplot
:
qplot(1,vector1,geom =boxplot)
或者(如@scoa指出的那样)将音乐会vector1作为 ggplot data.frame
code>仅对 data.frame
s进行操作,而不是对向量。 qplot
对于非常简单的情节是一个方便的包装。
I'm trying to make a simple boxplot with ggplot2. I've got a vector with numbers but when I type in the code an this error message appears:
Error: ggplot2 doesn't know how to deal with data of class numeric.
What does that mean?
Code:
vector1 <- c(x1, x2, x3, ...)
library(ggplot2)
ggplot(vector1, aes(x=x, y=value)) + boxplot()
解决方案
You can use qplot
as follows:
qplot(1,vector1, geom="boxplot")
Or (as @scoa pointed out) concert vector1 to a data.frame
as ggplot
operates only on data.frame
s and not on vectors. qplot
is a convenience wrapper for very simple plots.
这篇关于向量,ggplot2不知道如何处理类数字的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文