简体   繁体   English

正斜杠“ /”作为r中的文件路径分隔符

[英]forward slash '/' as file path separator in r

'/' could be used as file path separator in R. like: '/'可以用作R中的文件路径分隔符,例如:

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. 这不是R特定的,而是取决于操作系统。 At least for UNIX based platforms there is an official definition for this behaviour. 至少对于基于UNIX的平台,对此行为有一个正式定义。 In the Single UNIX Specification/3.267 Pathname you can read the following: Single UNIX Specification / 3.267路径名中,您可以阅读以下内容:

... Multiple successive slash characters are considered to be the same as one slash, except for the case of exactly two leading slash characters. ...多个连续的斜杠字符被认为与一个斜杠相同,但恰好是两个前导斜杠字符的情况除外。 ... ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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