[R] naming list entries dynamically
tlange at gwdg.de
tlange at gwdg.de
Thu Oct 23 22:29:58 CEST 2008
Hello,
I'm new to R and I'd like to dynamically assign names to the entries of a
list.
The situation is: I load several ascii-files from a folder. The data shall
be stored within the list structure, where the file names are assigned to
the list entries.
> flist
$file1.txt
[1] 1.0 1.2 1.4 1.6 1.8 2.0...
$file2.txt
[1] 1.0 1.2 1.4 1.6 1.8 2.0...
That's what I would like to see. But I got stucked coding it. Web search
doesn't helped me a lot. Here is some code I thought it somehow would work
like this:
<----
flist <- list()
fname <- list.files(pattern="some_pattern.txt")
for(i in 1:length(fname)) {
flist$"how_do_I_name_it_dynamically?" <- read.table(fname[i],
header=FALSE)
}
---->
Second: I assume to use lists in R more or less like Matlab-structs. I
hope that's not compleatly wrong... ?
Appreciating any help and hints,
Torsten
More information about the R-help
mailing list