I'm trying to import data from 100 text files and create data frames
that reflect their numbering.
The slow way would be to do the following:
peak1 <- read.table("1--peak--hist.txt", sep=",", header=TRUE)
peak2 <- read.table("2--peak--hist.txt", sep=",", header=TRUE)
peak3 <- read.table("3--peak--hist.txt", sep=",", header=TRUE)
...
I tried the following:
for (i in 1:100) {
peak[[i]] <- read.table(paste(i,"--one--hist.txt", sep=""), sep=",",
header=TRUE)
}
I receive an error saying "object 'peak' not found, which leads me to
believe R is trying to look in 'peak' at to whatever position 'i' has
iterated.
How can I create these data frame objects with the numbering to match
the input text files? That is to match the iterated 'i' of the loop?
Thanks for your help!
Batch importing data with respective naming
4 messages · Zeljko Vrba, Taylor Hermes, Adrián Cortés
On Tue, Apr 28, 2009 at 07:09:04PM -1000, Taylor Hermes wrote:
I tried the following:
Add this before for(): peak <- list()
for (i in 1:100) {
peak[[i]] <- read.table(paste(i,"--one--hist.txt", sep=""), sep=",",
header=TRUE)
}
It seems that this addition works, but has created just one object called 'peak' with all the data from those 100 files. I'd like each file to have a corresponding object containing the data. Thanks for your help!
On Tue, Apr 28, 2009 at 19:43, Zeljko Vrba <zvrba at ifi.uio.no> wrote:
On Tue, Apr 28, 2009 at 07:09:04PM -1000, Taylor Hermes wrote:
I tried the following:
Add this before for(): peak <- list()
for (i in 1:100) {
? ? ? peak[[i]] <- read.table(paste(i,"--one--hist.txt", sep=""), sep=",",
header=TRUE)
}
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090429/b3f43eef/attachment-0001.pl>