[R] Converting factor data into Date-time format
ggrothendieck at gmail.com
Tue Mar 13 17:51:38 CET 2012
On Tue, Mar 13, 2012 at 12:20 PM, Haojie Yan <yhj204 at googlemail.com> 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/yyyy
> These data were automatically read and saved as 'factor' in R. When I was
> trying to produce some plots (such as time series) with the above 'date and
> time' on x-axis, it caused some disodering problem, e.g. 1st of March 2012
> is in front of 10th of Feb. 2012 (if the data is from 10th Feb. 2012 to 1st
> of March 2012). I understand that I might have to convert them from
> 'factor' to 'date' first, so I tried using 'as.date'. But this method seems
> only work for data in format of 'd/m/y' and no further option that allows
> me to add hours and minutes.
> I checked online for other methods such as 'as.POSIX' and 'strptime' but
> none of them seem to offer me a quick solution.
> Please note that the data I received is recorded every 10 minutes so they
> are saved in the form of 'dd/mm/yyyy hh:mm', e.g. I only have data
> measured up to 'minute' NOT to 'second'. Are there any direct solution
> that I can solve this issue??
See Example 6 in the document Reading Data in zoo:
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
email: ggrothendieck at gmail.com
More information about the R-help