[R] importing multiple file form folder

Rui Barradas ruipbarradas at sapo.pt
Tue May 29 00:46:19 CEST 2012


I believe my already posted solution works.
I've just tried it with your examples.

url <- 
c("http://r.789695.n4.nabble.com/file/n4631640/channel_1_20120509_153744_00001.ddf",
     
"http://r.789695.n4.nabble.com/file/n4631640/channel_1_20120509_154744_00001.ddf")

flist <- url

And the rest is exactly the same. But, ok, I'll post it again.

Length <- read.table(flist[1], skip=26)[, 1]
Temp <- do.call(cbind, lapply(flist, function(x) read.table(x, 
skip=26)[, 2]))
colnames(Temp) <- paste("Temperature", seq_len(ncol(Temp)), sep=".")
result <- cbind(Length=Length, Temp)

head(result)
        Length Temperature.1 Temperature.2
[1,] -747.200       325.138       800.000
[2,] -746.185        18.874      -200.000
[3,] -745.171       488.420       800.000
[4,] -744.156        69.484       -78.434
[5,] -743.142       -70.252       129.180
[6,] -742.127      -200.000      -200.000

Em 28-05-2012 22:25, mpavlic escreveu:
> I managed to sort  something out with a for loop, but it's till not working
> ok...
>
>
>
> What it does is it loops through all files in the folder, it imports each
> file from line 763 on.
Line 763 on? I'm off by 737...

>   Than it just takes the second column (Temprerature)
> and binds the columns (cbind).
> BUT it just binds the values of the last file instead of EACH file.  Any
> ideas?
>
> Attached are two files for easier understanding...
If you ask for help, read the answers, please, the second file changed 
nothing.
(Nor it hurts to check what was posted before.)

>
> thanks, m
>
> http://r.789695.n4.nabble.com/file/n4631640/channel_1_20120509_153744_00001.ddf
> channel_1_20120509_153744_00001.ddf
> http://r.789695.n4.nabble.com/file/n4631640/channel_1_20120509_154744_00001.ddf
> channel_1_20120509_154744_00001.ddf
>
> --
> View this message in context: http://r.789695.n4.nabble.com/importing-multiple-file-form-folder-tp4631637p4631640.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Rui Barradas



More information about the R-help mailing list