[R] Help with time in R

David Winsemius dwinsemius at comcast.net
Tue Jul 20 14:41:15 CEST 2010


On Jul 20, 2010, at 7:33 AM, Sarah Chisholm wrote:

> Hi,
>
> I have a problem with the time formatting in R. I have entered time  
> in the format "MM:SS.xyz" and R has automatically classified this as  
> a factor, but I need it numerically. However when I use as.numeric()  
> it gives me totally different numbers. Is there any way I can tell R  
> to read thes input as a number?

There are ways using As methods of doing so, but I think those is a  
bit more complex than a learner at you level should be asked to  
implement. Guessing that you used one of the read functions to bring  
in the data (or possibly used hte data.frame function) , you are  
probably experiencing the effects of the default stringAsFactors=TRUE  
behavior. Try setting stringsAsFactors to FALSE. Then you can use the  
standard Date functions:

?Dates

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list