R-codes-tips

1. 在shell执行R文件

chmod 0755 file.R 

Rscript file.R

2.  载入数据

data(dune)

3. attach()

将data.frame添加到R的搜索路径中,所以可以省略数据框名

summary(mtcars)plot(mtcars$mpg)可以改写为attach(mtcars);plot(mpg)

detach()则为移除,但不影响data.frame本身同样功能的是with(),可以改写为with(mtcars, {plot(mpg)})

原文地址:https://www.cnblogs.com/pxy7896/p/6640366.html