简体   繁体   中英

forward slash '/' as file path separator in r

'/' could be used as file path separator in R. like:

path <- 'c:/users/john'
setwd(path)

However, the following also works:

path <- 'c:////users///john'
setwd(path)

It seems that the number of slash does not affect the above statement. I cannot find any rules about this. Does anyone have any clue on this? Thanks!

This is not R specific but depends on the operating system. At least for UNIX based platforms there is an official definition for this behaviour. In the Single UNIX Specification/3.267 Pathname you can read the following:

... Multiple successive slash characters are considered to be the same as one slash, except for the case of exactly two leading slash characters. ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM