Skip to content

factor conversion to date/time

4 messages · marjolein post, R. Michael Weylandt, Duncan Murdoch +1 more

#
Please don't triple post.

Michael
On Wed, May 2, 2012 at 8:08 AM, marjolein post <mayo_jojo at hotmail.com> wrote:
#
On 02/05/2012 8:08 AM, marjolein post wrote:
To stop the conversion to factors, use argument stringsAsFactors=FALSE 
when you read the file, or even better, options(stringsAsFactors=FALSE) 
for a global change.

To convert a string, specify the format (following the instructions in 
?strptime):

x <- "1981-01-02T08:00I"
strptime(x, format="%Y-%m-%dT%H:%MI")

Duncan Murdoch
#
Try something like this.  Convert the vector to character and grab the first 10 characters then convert to a date.

aa <- as.factor("1981-01-02T08:00I")
aa <- as.character(aa)
aa <- substr(aa, 1, 10)
class(b)

John Kane
Kingston ON Canada
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!