2014-02-27 60 views
0

我想運行在R上的下面的代碼,從here採取:錯誤:找不到功能「指導」

library(ggplot2) 
bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() 
bp 
# Remove legend for a particular aesthetic (fill) 
bp + guides(fill=FALSE) 

不幸的是,在最後的命令,系統說:

Error: could not find function "guides" 

我做了一個小小的搜索,發現指南功能包含在「尺度」包中,安裝它然後用以下方式調用:

library(scales) 

圖書館似乎正在加載,但仍然得到相同的錯誤。任何線索?我使用的是全新安裝的debian。

我試圖

bp + scale_fill_discrete(guide=FALSE) 

但出現以下錯誤

Error in get(x, envir = this, inherits = inh)(this, ...) : 
    unused argument(s) (guide = FALSE) 

中的R版本的細節

> R.Version() 
$platform 
[1] "x86_64-pc-linux-gnu" 

$arch 
[1] "x86_64" 

$os 
[1] "linux-gnu" 

$system 
[1] "x86_64, linux-gnu" 

$status 
[1] "" 

$major 
[1] "2" 

$minor 
[1] "15.1" 

$year 
[1] "2012" 

$month 
[1] "06" 

$day 
[1] "22" 

$`svn rev` 
[1] "59600" 

$language 
[1] "R" 

$version.string 
[1] "R version 2.15.1 (2012-06-22)" 

$nickname 
[1] "Roasted Marshmallows" 

和我的版本的Debian

$ lsb_release -a 
No LSB modules are available. 
Distributor ID: Debian 
Description: Debian GNU/Linux 7.4 (wheezy) 
Release: 7.4 
Codename: wheezy 
+4

你使用的是什麼版本的ggplot2?此代碼適用於我。 – BrodieG

+0

同上。另外爲什麼你不使用其他兩個選項中的任何一個? – Wave

+0

此代碼也適用於我,請嘗試在乾淨的環境中運行此代碼,僅加載ggplot2。這個錯誤可能是由於與代碼或其他庫的命名衝突。 – df239

回答

1

該問題已通過更新R版本解決。 Debian Wheezy穩定版本附帶了一個相當古老的R版本。爲了更新R,我跟着這個準則

http://cran.r-project.org/bin/linux/debian/

之後,人們必須更新舊R模塊

update.packages(checkBuilt = TRUE, ask = FALSE) 

然後上面寫的例子完美的作品!