R get working directory: getwd()
R to set working directory:
From Windows, Rstudio session -> set working directory -> choose directory
Is the same as setwd()
Run R in Rstudio:
Ctrl + Enter and use mouse to highlight the chunk of code that you want to run.
Ctrl + shift + Enter run the whole file
没有在R里运行R文件这种东西。
你要在terminal里面运行。Rscript xxxxx.r
In R environment, this sentence is to echo everything in this R file, I used it in Rstudio
source(“trees_read_csv.r”, echo = TRUE)
本文介绍了如何在R和RStudio中设置工作目录,包括使用`getwd()`和`setworkingdirectory()`,以及在RStudio中通过`source()`和`Ctrl+Enter`/`Ctrl+Shift+Enter`运行代码块。还提到在R环境中,使用`echo=TRUE`显示代码内容,以及在终端中通过`Rscript`执行R文件。
929





