R ggplot2功能不工作

R ggplot2功能不工作,r,package,ggplot2,R,Package,Ggplot2,可能重复: 问题:为什么我的ggplot2功能不工作? 背景:Ubuntu 12.04,Gnome桌面,R2.15.1,镜像: 首先,它说下载的源程序包位于“/tmp/Rtmp2GMNV8/downloaded_程序包”中,没有“/tmp/Rtmp2GMNV8/downloaded_程序包” 其次,安装了ggplot2。为什么“找不到函数”qplot“” 我找了好几个小时,在网上找不到任何答案。有人知道发生了什么事吗 读数: emilio@dog:~/R$ sudo R R versio

可能重复:

问题:为什么我的ggplot2功能不工作?
  • 背景:Ubuntu 12.04,Gnome桌面,R2.15.1,镜像:

  • 首先,它说下载的源程序包位于“/tmp/Rtmp2GMNV8/downloaded_程序包”中,没有“/tmp/Rtmp2GMNV8/downloaded_程序包”

  • 其次,安装了ggplot2。为什么“找不到函数”qplot“”

我找了好几个小时,在网上找不到任何答案。有人知道发生了什么事吗

读数:

emilio@dog:~/R$ sudo R

R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"

# I've taken the liberty of omitting a few lines

> install.packages("ggplot2", dependencies=TRUE)
Installing package(s) into ‘/usr/local/lib/R/site-library’
[...]
* DONE (SparseM)
* DONE (sp)
* DONE (mvtnorm)
* DONE (evaluate)
* DONE (Hmisc)
* DONE (maps)
* DONE (hexbin)
* DONE (gpclib)

* installing *source* package ‘ggplot2’ ...
** package ‘ggplot2’ successfully unpacked and MD5 sums checked
** R
** data
**  moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded

* DONE (ggplot2)
* DONE (quantreg)
* DONE (mapproj)
* DONE (maptools)
* DONE (multcomp)
* DONE (testthat)

The downloaded source packages are in
    ‘/tmp/Rtmp2GMNV8/downloaded_packages’
> help(qplot)
No documentation for ‘qplot’ in specified packages and libraries:
you could try ‘??qplot’
> help(ggplot)
No documentation for ‘ggplot’ in specified packages and libraries:
you could try ‘??ggplot’
> data(diamonds, package="ggplot2")
> head(diamonds)
  carat       cut color clarity depth table price    x    y    z
1  0.23     Ideal     E     SI2  61.5    55   326 3.95 3.98 2.43
2  0.21   Premium     E     SI1  59.8    61   326 3.89 3.84 2.31
3  0.23      Good     E     VS1  56.9    65   327 4.05 4.07 2.31
4  0.29   Premium     I     VS2  62.4    58   334 4.20 4.23 2.63
5  0.31      Good     J     SI2  63.3    58   335 4.34 4.35 2.75
6  0.24 Very Good     J    VVS2  62.8    57   336 3.94 3.96 2.48
> qplot(carat, price, data = diamonds)
Error: could not find function "qplot"

emilio@dog:~$ cd /tmp/Rtmp2GMNV8/downloaded_packages
bash: cd: /tmp/Rtmp2GMNV8/downloaded_packages: No such file or directory

您需要先加载包。参见joran在评论中给出的链接,但:

library(ggplot2)

qplot(caret, price, data=diamonds)

我认为这值得一提。哦,在那里。啊[咒骂删除]。新手的错误。我的错。