[R] reading and storing files in the workspace
Luis Ridao Cruz
Luisr at frs.fo
Tue Jul 31 14:25:04 CEST 2007
R-help,
I have a vector containing (test) some file names.
The files contents are matrixes.
> test
[1] "aaOki.txt" "aOki.txt" "bOki.txt" "c1Oki.txt"
"c2Oki.txt" "c3Oki.txt" "cOki.txt" "dOki.txt" "dyp100.txt"
"dyp200.txt"
[11] "dyp300.txt" "dyp400.txt" "dyp500.txt" "dyp600.txt"
"dyp700.txt" "dyp800.txt" "eOki.txt" "FBdyp100.txt"
"FBdyp150.txt" "FBdyp200.txt".............
What I want to do is to import to R using the same file name
and remove the ".txt" extension out of the object name.
Something like this:
for(i in test)
gsub("\\.", "", paste(i, sep = "")) <- read.table(file = paste(i, sep =
""), header = TRUE)
But I get the following message:
Error in gsub("\\.", "", paste(i, sep = "")) <- read.table(file =
paste(i, :
target of assignment expands to non-language object
Thanks in advance.
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 5.1
year 2007
month 06
day 27
svn rev 42083
language R
version.string R version 2.5.1 (2007-06-27)
More information about the R-help
mailing list