find the parent directory of a directory in r

You can use the dirname() function in R to find the parent directory of a directory.

Here's an example:

main.r
# set the path to the directory
mydir <- "/path/to/my/directory/"

# get the parent directory using dirname()
parentdir <- dirname(mydir)

# print the parent directory
cat("The parent directory of", mydir, "is", parentdir)
223 chars
9 lines

This code will print the path to the parent directory of mydir.

gistlibby LogSnag