Displaying 2 results from an estimated 2 matches for "t_class2_".
2005 Feb 03
3
Reading Dates in a csv File
Hi all. I'm reading in a flat, comma-delimited flat file using read.csv.
It works marvelously for the most part. I am using the colClasses argument
to, basically, create numeric, factor and character classes for the columns
I'm reading in. However, a couple of the fields in the file are date
fields. I'm fully aware that POSIXct can be used as a class, however the
field must obey,
2009 Oct 05
6
Date-Time-Stamp input method for user-specific formats
...ny help whatsoever, however tenuous?
CODE, DATA & RESULTS:
Function to Read required data, intended to make the datetime column of the
data (example given further below) into POSIXct values:
<<<
spot_frequency_readin <- function(file,nrows=-1) {
# create temp class
setClass("t_class2_", representation("character"))
setAs("character", "t_class2_", function(from) {sapply(from, function(x) {
if (nchar(x)==10) {
as.POSIXct(strptime(x,format="%d/%m/%Y"))
}
else {
as.POSIXct(strptime(x,format="%d/%m/%Y %H:%M:%S"))
}
}
)
}
)
#(f...