Re: [R] extract date time from a text file

2010-06-18 Thread Sebastian Kruk
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","

Re: [R] extract date time from a text file

2010-06-18 Thread Gabor Grothendieck
On Fri, Jun 18, 2010 at 10:58 AM, Sebastian Kruk 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. Suppo

Re: [R] extract date time from a text file

2010-06-18 Thread Henrique Dallazuanna
Try this: Lines <- "2007-12-03 13:50:17 Juan Perez" read.csv2(textConnection(gsub("(:\\d{2})\\s", "\\1;", Lines)), header = FALSE) On Fri, Jun 18, 2010 at 11:58 AM, Sebastian Kruk 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:m

Re: [R] extract date time from a text file

2010-06-18 Thread Joris Meys
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") t

Re: [R] extract date time from a text file

2010-06-18 Thread jim holtman
You data has 4 fields (separated by blanks) and that is what you are reading. Just write some code to combine the fields: newDF <- data.frame(time=as.POSIXct(paste(oldDF[[1]], oldDF[[2]]), name=paste(oldDF[[3]], oldDF[[4]])) On Fri, Jun 18, 2010 at 10:58 AM, Sebastian Kruk wrote: > I a have a

[R] extract date time from a text file

2010-06-18 Thread Sebastian Kruk
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. By