tags:

views:

337

answers:

1

Hi,

I wondering if there is a quick way to extract the file name from the file full path in R (part of a file path) without the hassle of manipulating string?

The equivalent in Java would be:

File f = new File ("C:/some_dir/a")
f.getName() //output a
f.getFullAbsolutePath() //output c:/some_dir/a

Thanks, Derek

+13  A: 

Use

basename("C:/some_dir/a")
> [1]  "a"

dirname("C:/some_dir/a")
>[1] "C:/some_dir"
mjv