Skip to content
Prev 43721 / 398503 Next

Date Time Conversion problems...

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
Message-ID: <20040205093542.N935@hortresearch.co.nz>
In-Reply-To: <2F3262756375D411B0CC00B0D049775D01A4CDB9@westpark>; from sway@tanox.com on Wed, Feb 04, 2004 at 08:31:56AM -0600