在 r 中移动文件时出现错误
我正在尝试使用以下代码将一些文件从一个位置移动到另一个位置:
#exclude files with name .maf
filez <- grep(list.files(path="."), pattern='.maf', invert=TRUE, value=TRUE)
filez <- data.frame(filez)
#select files with sepcial chr at 14 & 15 position in file name
Tumor <- filez %>% filter(between(as.integer(substr(filez, 14, 15)), 01, 09))
dir.create("Tumor")
file.move(Tumor$filez, "Tumor")
但是我收到错误,
file.move(Tumor$filez, "Tumor")
Error in argchk_move_files(files = files, destinations = destinations, :
Assertion on 'files' failed: Must be of type 'character', not 'factor'.
我不知道为什么会出现错误。
I am trying to move some files from one location to another using below code:
#exclude files with name .maf
filez <- grep(list.files(path="."), pattern='.maf', invert=TRUE, value=TRUE)
filez <- data.frame(filez)
#select files with sepcial chr at 14 & 15 position in file name
Tumor <- filez %>% filter(between(as.integer(substr(filez, 14, 15)), 01, 09))
dir.create("Tumor")
file.move(Tumor$filez, "Tumor")
However I getting error
file.move(Tumor$filez, "Tumor")
Error in argchk_move_files(files = files, destinations = destinations, :
Assertion on 'files' failed: Must be of type 'character', not 'factor'.
I donot know why error is coming.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在文件夹中设置了一些文件来说明:
将一些文件放入向量中(这对你来说有点不同,因为我认为你得到的所有文件不是
.maf
但这个足够接近):现在使用从位置 4 和 5 中的数值在 3 到 6 之间导出的条件对该向量进行子集化:
完成。无需创建数据框或使用
过滤器
。I've set up some files in a folder to illustrate:
Get some files into a vector (this is a bit different to you because I think you are getting all files that aren't
.maf
but this is close enough):Now subset that vector using the condition derived from the numeric value in positions 4 and 5 being between 3 and 6:
Done. No need to create a data frame or use
filter
.