[英]What would be the equivalent to str.split(“/path/to/file”, os.sep) from Python in R
I thought there would be something similar in R to split up a filepath by the operating system separator, but couldn't find anything super useful.我认为 R 中会有类似的东西通过操作系统分隔符分割文件路径,但找不到任何超级有用的东西。
I do not know Python but from your description this is most likely what you are looking for:我不知道 Python 但根据您的描述,这很可能是您正在寻找的:
.Platform$file.sep
returns "/" on my comuter as default file separator.在我的通勤机上返回“/”作为默认文件分隔符。 You can further use
basename()
and dirname()
to split a path into it's components.您可以进一步使用
basename()
和dirname()
将路径拆分为其组件。
See also this question: Split a file path into folder names vector另请参阅此问题: Split a file path into folder names vector
See strsplit
见
strsplit
strsplit("/path/to/file", .Platform$file.sep)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.