getwd() function
getwd() stands forget working directory. It is used to get the current working directory of the environment.
Syntax:
getwd()
We can also see the total number of files in the present working directory. For that, we have to use the length function.
Syntax:
length(list.files())
If we have to use the display the filenames, then the command is
list.files()
Example :
In this example, we will be using the getwd() function to get the current working directory.
R
getwd () |
Output:
"C:/Users/Ramu/saisri"
Example :
Here, we will be using the getwd() function to get the length of the list of the files present in the working directory of the R console.
R
# get total file count print ( length ( list.files ())) # get file names print ( list.files ()) |
Output:
[1] 2 [1] "ai.R" "ramu.R"
How to Use setwd and getwd in R?
In this article, we will discuss how to use setwd and getwd in the R programming language.
Contact Us