using as.POSIXlt on multiple columns or multiple objects

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

using as.POSIXlt on multiple columns or multiple objects

Farrel Buchinsky
If I want to convert one column to date and time format that R can
understand and manipulate then I would do this

initial$Started<-as.POSIXlt(initial$Started)

But what happens if I have many such columns and I do not want to have
my code be stuffed with 10 similar lines (one for each variable aka
column aka vector aka object)

I thought I could be clear and use the list function and do this.
list(initial$Started ,initial$Finished,full.ques$started.ful
,full.ques$finished.ful) <- lapply(list(initial$Started
,initial$Finished,full.ques$started.ful
,full.ques$finished.ful),as.POSIXlt)

But I got:
Error in list(initial$Started, initial$Finished, full.ques$started.ful,  :
  could not find function "list<-"

I am clearly missing some basic R issue here. What am I missing?


--
Farrel Buchinsky

______________________________________________
[hidden email] 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.