To find the contents of a directory in R, you can use the list.files()
function. This function returns a character vector of the file names in a directory.
main.r144 chars6 lines
By default, list.files()
returns all files in a directory (including hidden files). You can use the pattern
argument to filter for files that match a specific pattern. For example:
main.r85 chars3 lines
This will return a vector of file names that end with .R
.
Note: When specifying the path of a directory in R, make sure to use forward slashes (/
) instead of backslashes (\
).
gistlibby LogSnag