为什么使用 file.create 在 R 中创建多个目录会导致 Windows 中的 'path' 参数无效
Why does creating multiple directories in R using file.create cause invalid 'path' argument in Windows
我有这个简单的例子,我想如何从 R 中的字符向量创建多个文件夹:
folder <- c("test","names","for","rep","example")
list_of_paths <- paste("C:/Users/admin/Desktop/TEST123/",folder, sep="")
dir.create(list_of_paths)
它导致错误,我无法解决,说 Error in dir.create(list_of_paths) : invalid 'path' argument
但是当我使用像
这样的单个字符串时
dir.create("C:/Users/admin/Desktop/TEST123/test")
有效。如果有人能在这里指出正确的方向或告诉我错误的原因,我将不胜感激。谢谢你,晚上好,
康拉德
根据?dir.create
path - a character vector containing a single path name.
所以,我们可能需要循环
sapply(list_of_paths, dir.create)
我有这个简单的例子,我想如何从 R 中的字符向量创建多个文件夹:
folder <- c("test","names","for","rep","example")
list_of_paths <- paste("C:/Users/admin/Desktop/TEST123/",folder, sep="")
dir.create(list_of_paths)
它导致错误,我无法解决,说 Error in dir.create(list_of_paths) : invalid 'path' argument
但是当我使用像
这样的单个字符串时dir.create("C:/Users/admin/Desktop/TEST123/test")
有效。如果有人能在这里指出正确的方向或告诉我错误的原因,我将不胜感激。谢谢你,晚上好,
康拉德
根据?dir.create
path - a character vector containing a single path name.
所以,我们可能需要循环
sapply(list_of_paths, dir.create)