How can I determine the current directory name in R?

后端 未结 2 2056
庸人自扰
庸人自扰 2021-01-07 19:03

The only solution I\'ve encountered is to use regular expressions and recursively replace the first directory until you get a word with no slashes.

gsub(\"/\         


        
2条回答
  •  长发绾君心
    2021-01-07 19:33

    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"
    

提交回复
热议问题