I have a couple txt files in a directory
dayton1.txt
datton2.txt
...
dakton50.txt
and I want to create variables with the file names as names and read the corresponding files. How can I do this in R?
Thanks!
I have a couple txt files in a directory
dayton1.txt
datton2.txt
...
dakton50.txt
and I want to create variables with the file names as names and read the corresponding files. How can I do this in R?
Thanks!
You want list.files()
, see it's help page at ?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"