[R] Date Time Conversion problems...

Patrick Connolly p.connolly at hortresearch.co.nz
Wed Feb 4 21:35:42 CET 2004


On Wed, 04-Feb-2004 at 08:31AM -0600, Shawn Way wrote:

|> At one time (version 1.7), the code below used to work for converting and
|> extracting based on the Date Time.  In version 1.8.1, something changed I
|> know, but I cannot for the life of me figure out what...


[...]

|> 
|> The error I get is from line 4, 
|> 
|> > data2$Date <- strptime(as.character(data2$Date),format="%m/%d/%Y")
|> Error in "$<-.data.frame"(`*tmp*`, "Date", value =
|> strptime(as.character(data2$Date),  : 
|> 	replacement has 9 rows, data has 230
|> 
|> This used to work for replacing the dates with POSIX values...

Try:

data2$Date <- as.POSIXct(strptime(as.character(data2$Date),format="%m/%d/%Y"))

You'll find that it prints the date labels more usefully in 1.8.1

HTH

-- 
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand 
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~




More information about the R-help mailing list