[R] extract date time from a text file

Sebastian Kruk residuo.solow at gmail.com
Fri Jun 18 19:20:20 CEST 2010


Thanks, yes, I would like to do it in one try.

I a have a text file called archivo where every line is like that:

"2007-12-03 13:50:17 Juan Perez"

("yy-mm-dd hh:mm:ss First Name Second Name")

My code is it:

datos <- read.delim(archivo,header=FALSE,sep= " ",dec=".",
	col.names=c("date","time","fname", "sname",comment="#",
	colClasses = c("character","character","numeric","numeric"))
f_h <- paste(datos[,"date"],datos[,"time"],sep=" ")
fecha_hora <- strptime(f_h, "%y-%m-%d %H:%M:%S")

Bye,

Sebastián.



More information about the R-help mailing list