Re: [R] Converting factor data into Date-time format

2014-09-30 Thread PIKAL Petr
gt; project.org] On Behalf Of David L Carlson > Sent: Tuesday, September 30, 2014 10:43 PM > To: tandi perkins; r-help@r-project.org > Subject: Re: [R] Converting factor data into Date-time format > > First, use stringsAsFactors=FALSE with the read.csv() function. That > will prevent

Re: [R] Converting factor data into Date-time format

2014-09-30 Thread David L Carlson
First, use stringsAsFactors=FALSE with the read.csv() function. That will prevent the conversion to factors. Then try to convert date and time to datetime objects. - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-435

Re: [R] Converting factor data into Date-time format

2012-03-13 Thread R. Michael Weylandt
No problem. A pro-tip for future posts: the dput() function creates a plain text representation of the data in question which is great for email and is nicely copy-and-pasteable. It wasn't so much a thing here, but for large or complicated data sets, the regular console printout doesn't always rev

Re: [R] Converting factor data into Date-time format

2012-03-13 Thread R. Michael Weylandt
Just a little typo: see below. On Tue, Mar 13, 2012 at 1:00 PM, Haojie Yan wrote: > Dear Michael, > > Thanks a lot for your hints. > > I have just had a try as below but still got back some error messages as > shown: > > The object containing the 'date_time' data is named 'INTERVAL_END_TIME' and

Re: [R] Converting factor data into Date-time format

2012-03-13 Thread Gabor Grothendieck
On Tue, Mar 13, 2012 at 12:20 PM, Haojie Yan wrote: > Dear R-user, > > I have read a dataset from .csv file into R. This dataset includes one > column containing some data in 'date and time' format, e.g. 'dd/mm/ > hh:mm'. > > These data were automatically read and saved as 'factor' in R. When

Re: [R] Converting factor data into Date-time format

2012-03-13 Thread Joshua Wiley
This is just a little comment to supplement Michael's excellent solution. If there are even a few (e.g., 5 each) repeated values, this: as.POSIXct(as.character(levels(x)), format = "%d/%m/%Y %H:%M")[x] will be substantially faster, with the speed gains strongly associated with the number of repl

Re: [R] Converting factor data into Date-time format

2012-03-13 Thread R. Michael Weylandt
as.POSIXct(as.character(FACTORHERE), format = "%d/%m/%Y %H:%M") Michael On Tue, Mar 13, 2012 at 12:20 PM, Haojie Yan wrote: > Dear R-user, > > I have read a dataset from .csv file into R. This dataset includes one > column containing some data in 'date and time' format, e.g. 'dd/mm/ > hh:mm'