R language – path setting and working directory modification

Path setting in R language
Software path setting is important for memory management, working data storage, and getting to the bottom of things. Therefore, a reasonable setting of the relevant path in R can facilitate the management of relevant documents, improve the efficiency of learning R language, and establish their own habit system.
The path setting in R mainly includes the following aspects:
Path to the working directory Path to the installation package


Working directory
1. Use the geTWd () function to display the current working directory;

getwd()

2. Change the current directory using the seTWd () function;

setwd("D:/R")

Note: the
(1) function setwd() does not automatically create a directory that does not exist. If necessary, you can use the function dir. Create () to create a new directory, then use setwd() to point the working directory to the new directory.
(2) Dir. Create () in R is non-cascading, meaning that only one “/” path can be created at a time. If you need two “/” paths, you need to create them twice with dir. Create () before the file is created successfully. Then follow the example and use seTWd () to set it.
(3) The seTWd () function is to set a temporary work path. 3. Use the RStudio window to permanently change the working directory
A.
B.

 
Package installation
Once and for all: (Run RStudio as administrator) write the following command in R:

.libPaths("C:/Program Files/R/R-3.5.2/library")

or
Run RStudio as an administrator


 
 
 

Read More: