代码之家  ›  专栏  ›  技术社区  ›  iod

在R中使用“plot”时添加的随机数据

  •  0
  • iod  · 技术社区  · 7 年前

    我是偶然发现的,我不知道发生了什么。有人能解释一下吗?

    plot(iris$Petal.Length,iris$foobar)
    

    产生以下结果:

    enter image description here

    即使没有 iris$foobar ,甚至只是 foobar 对象。y轴数据从何而来?我在另一个data.frame中遇到过这种情况,所以这并不是iris独有的(事实上,我在iris上尝试过,以查看我的其他data.frame是否有问题)。为什么x轴被标记为“索引”?

    版本数据:
    拱门x86\u 64
    操作系统mingw32
    系统x86\u 64,mingw32

    专业3

    2017年

    第30天
    svn版本73796
    语言R
    绰号吃风筝树

    loadedNamespaces()
     [1] "Rcpp"         "HistData"     "bindr"        "magrittr"    
     [5] "grDevices"    "tidyselect"   "munsell"      "wordcloud"   
     [9] "colorspace"   "R6"           "rlang"        "stringr"     
    [13] "plyr"         "dplyr"        "tools"        "utils"       
    [17] "grid"         "gtable"       "stats"        "datasets"    
    [21] "yaml"         "lazyeval"     "assertthat"   "tibble"      
    [25] "base"         "bindrcpp"     "purrr"        "RColorBrewer"
    [29] "ggplot2"      "tidyr"        "graphics"     "glue"        
    [33] "slam"         "stringi"      "compiler"     "pillar"      
    [37] "methods"      "scales"       "lubridate"    "pkgconfig"   
    [41] "Cairo" 
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   bobbel    7 年前

    d$foobar 正在被忽略 plot() ,因为 iris$foobar 是 NULL .

    比较 plot(iris$Petal.Length) 或 plot(iris$Petal.Length, NULL) .

        2
  •  0
  •   HolgerBarlt    7 年前

    在我看来,data.frame中似乎没有foobar,因为只调用 plot(iris$Petal.Length) . 因为第二个参数是空的 is.null(iris$foobar) 它将被忽略。。。。