[R] extract date time from a text file

Joris Meys jorismeys at gmail.com
Fri Jun 18 18:33:32 CEST 2010


As the footer says:
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

There's probably another way using readLines or so to do it in one
try, but say you used :
frame <- read.delim("some_file.ext")

then

library(chron)
newframe$name <- paste(frame[,3],frame[,4])
newframe$dates <- chron(frame[,1],frame[,2],format=c(dates = "y/m/d",
times = "h:m:s"))

Cheers
Joris

On Fri, Jun 18, 2010 at 4:58 PM, Sebastian Kruk <residuo.solow at gmail.com> wrote:
> I a have a text file where every line is like that:
>
> "2007-12-03 13:50:17 Juan Perez"
> ("yy-mm-dd hh:mm:ss First Name Second Name")
>
> I would like to make a data frame with two column one for date and the
> other one for name.
>
> When I use read.delim it was transformed in a data frame with 4 colums.
>
> Bye,
>
> Sebastián.
>
> ______________________________________________
> 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.
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



More information about the R-help mailing list