Linux上要讓Rstudio用不同的版本開,指令如下:
- PATH="/opt/R/4.1.2/bin:$PATH" rstudio
安裝在Linux上面的R,可用下面的指令來看library路徑:
在Debian裏面預設會顯示(前面的數字代表使用套件的順序、藍色代表在R環境下安裝、綠色代表在系統環境下安裝):
> a <- matrix(c(5,6,5,6,5,6), nrow=3, ncol=2)
> b <- matrix(c(7,8,7,8,7,8), nrow=3, ncol=2)
> c <- matrix(c(9,0,9,0,9,0), nrow=3, ncol=2)
> print(a)
[,1] [,2]
[1,] 5 6
[2,] 6 5
[3,] 5 6
> d <- InsectSprays
> s <- split(d, d$spray)
> tapply(df$count, df$spray, summary)
> lapply(s, function(x) summary(x$count))
> sapply(s, function(x) summary(x$count))
A B C D E F
Min. 7.00 7.00000 0.000000 2.000000 1.00 9.00000
1st Qu. 11.50 12.50000 1.000000 3.750000 2.75 12.50000
Median 14.00 16.50000 1.500000 5.000000 3.00 15.00000
Mean 14.50 15.33333 2.083333 4.916667 3.50 16.66667
3rd Qu. 17.75 17.50000 3.000000 5.000000 5.00 22.50000
Max. 23.00 21.00000 7.000000 12.000000 6.00 26.00000
這邊可以注意tapply與lapply出來的結果會是相同的,但用sapply比較易讀~Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package "methods" in options("defaultPackages") was not found
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package 'utils' in options("defaultPackages") was not found
Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset])
error: invalid value for 'editor'
In addition: Warning message:
package 'stats' in options("defaultPackages") was not found
During startup - Warning messages:
1: package 'methods' in options("defaultPackages") was not found
2: Setting LC_CTYPE failed, using "C"
![]() |
| 圖片來自dreadpiratemama |