zoukankan      html  css  js  c++  java
  • 异常:Error: Aesthetics must either be length one, or the same length as the dataProblems:AData

    今天遇到一个异常,代码如下:

    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 <- 2
    j <- 3
    p <- ggplot(data=AData, aes(AData[, i], AData[, j])) + geom_point() + theme_bw()
    p # all right p <- 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

    但是与我遇到的问题不大一样,暂无解.
     
  • 相关阅读:
    day4-叶卓睿
    day3-任清宇
    Cisco show interface 命令详解
    k8s入门系列之guestbook快速部署
    k8s入门系列之扩展组件(二)kube-ui安装篇
    k8s入门系列之扩展组件(一)DNS安装篇
    k8s入门系列之介绍篇
    k8s入门系列之集群安装篇
    SPAN, RSPAN, ERSPAN
    在Linux下记录所有用户的登录和操作日志
  • 原文地址:https://www.cnblogs.com/lizichao/p/4917649.html
Copyright © 2011-2022 走看看