[R] importing multiple file form folder

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


Hi again all, 

@Rui, melt did the trick. Thanks!


I managed to make this thing work somehow. ABellow is the script for this :
		

		setwd("C:/Users/mpavlic/Desktop/HE Krsko/HEK/FOC/Data/Jun/DDF")
		library(reshape2)
		library(sqldf)
		#imena datotek
		txt_files = list.files(pattern = '*.ddf');
		flist<-txt_files
		flistNew <- sub("^channel 1 ([0-9 ]+).*", "\\1", flist)
		flistNew <-c("D",flistNew)
		# koordinate posamezne lokacije vzdolž FOC
		coordinate<-read.csv("coordinate_linija1.csv", sep=";", dec=".")[,2:4]
		D<-seq(1,970,by=1)
		coordinate<-(cbind(D,coordinate))
		#dolžina vzdolž FOC
		#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])) 
		Temp1<-as.data.frame(cbind(D,Temp))
		colnames(Temp1)<-flistNew
		# zdruzi v tableo, tako da so temperature za posameni file po vrsticah 
		dm <- melt(Temp1, id=("D"))
		dm <-data.frame(X=11.11, Y=11.11, dolzina=11.11, dm)

But i have another problem...
Is it possible to trnasform the names of each file which are listed in the
variable txt_files to official R DateTime format? For example :
so that this :	"channel 1 20120601 003507 00001.ddf"  would be saved like
this "2012-06-07 00:35:07"

Thanks for the help

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



More information about the R-help mailing list