我在目录中有几个txt文件
dayton1.txt
datton2.txt
...
dakton50.txt
我想用文件名作为名称创建变量并读取相应的文件。我怎么能在R?中做到这一点?
谢谢!
答案 0 :(得分:6)
您想要list.files()
,请在?list.files
查看帮助页面。 E.g:
R> getwd()
[1] "/blah/blah/packages/analogue/analogue/pkg"
R> list.files()
[1] "data" "DESCRIPTION" "DESCRIPTION~" "inst" "man"
[6] "NAMESPACE" "NAMESPACE~" "R" "src" "tests"
[11] "vignettes"
R> list.files("./inst")
[1] "ChangeLog" "ChangeLog~" "CITATION" "CITATION~" "COPYING"
[6] "doc" "THANKS" "TODO"