Exception: Error:aesthetics must either be length one, or the same length as the Dataproblems:adata

Source: Internet
Author: User
Tags ggplot

Today encountered an exception, the code is as follows:

set.seed(12345)require(ggplot2)AData <- data.frame(Glabel=LETTERS[1:7], A=rnorm(7, mean = 0, sd = 1), B=rnorm(7, mean = 0, sd = 1))
i <- 2j <- 3p <- ggplot(data=AData, aes(AData[, i], AData[, j])) + geom_point() + theme_bw()
p # all rightp <- p + geom_text(aes(data=AData, label=Glabel), size=3, vjust=1.25, colour="black")
p # Error: Aesthetics must either be length one, or the same length as the dataProblems:AData

下面的代码就ok:
example <- data.frame(r=c(5,4,3),theta=c(0.9,1.1,0.6))
myplot <- ggplot(example, aes(r, theta)) + geom_point(size=3.5) +
geom_text(aes(label=rownames(example)), size=4.4, hjust=0.5, vjust=-1)

根据异常信息,应该是说Glabel与AData的长度不同,但具体什么原因不了解。

stackover上面的解释是:对于0.9.0版本的ggplot2有这个问题,0.9.1版本中已经解决。(http://stackoverflow.com/questions/10628847/geom-boxplot-with-precomputed-values)

利用installed.packages()命令,看到我的ggplot2的版本是1.0.1,应该没有问题,奇怪。

stackoverflow上另外一个类似的帖子是:http://stackoverflow.com/questions/20057452/aesthetics-must-either-be-length-one-or-the-same-length-as-the-dataproblems

但是与我遇到的问题不大一样,暂无解.
 

Exception: Error:aesthetics must either be length one, or the same length as the Dataproblems:adata

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.