[R] importing multiple file form folder

mpavlic matevz.pavlic at gi-zrmk.si
Sun Jun 10 00:25:50 CEST 2012


Hi all, 

i managed to (with the help of most posts here) using bellow code :

	>setwd("C:/Users/mpavlic/Desktop/test")
	>txt_files = list.files(pattern = '*.ddf');
	>flist<-txt_files
	>flistNew <- sub("^channel 1 ([0-9 ]+).*", "\\1", flist)
	>coordinate<-read.csv("coordinate_linija1.csv", sep=";", dec=".")[,2:4]

	>Length <- read.table(flist[1], skip=917, nrows=970)[, 1] 
	>Temp <- do.call(cbind, lapply(flist, function(x) read.table(x, skip=917,
nrows=970)[, 2])) 
	>colnames(Temp) <- paste(flistNew, seq_len(ncol(Temp)), sep=".") 
	>result <- cbind(Length=Length, coordinate, Temp) 

...join all files in one folder in one big table. But the merging here is
done by columns as seen in attachment-asColumns.csv (so that every column
form certain file is added to the table "result" as a column). 

For better reperesentation of data I would now need data to be added as rows
in a table, with corresponding name of the file as a value in column.
Resulting table should look something like in an attached file asRows.csv. 
Is that possible?

Hope i exaplined it ok, because it's a bit difficult. Thanks for any
idea....
http://r.789695.n4.nabble.com/file/n4632909/asColumns.csv asColumns.csv 
http://r.789695.n4.nabble.com/file/n4632909/asRows.csv asRows.csv 

--
View this message in context: http://r.789695.n4.nabble.com/importing-multiple-file-form-folder-tp4631637p4632909.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list