How can I determine the current directory name in R? How can I determine the current directory name in R? r r

How can I determine the current directory name in R?


Your example code doesn't work for me, but you're probably looking for either basename or dirname:

> getwd()[1] "C:/cvswork/data"> basename(getwd())[1] "data"> dirname(getwd())[1] "C:/cvswork"


If you didn't know basename (and I didn't), you could have used this:

tail(strsplit(getwd(), "/")[[1]], 1)