See ?read.zoo in the zoo package and read the three vignettes
library(zoo)
vignette(package = "zoo")
vignette("zoo")
# etc.
and help files for more info.
On Wed, Apr 29, 2009 at 6:52 PM, Achilles Venetoulias
<axilleas at stanfordalumni.org> wrote:> I have a text (csv) file) with two columns: dates and numeric measurements.
> I read it using read.table and the dates get read as a factor, with as many
> levels as there are dates in the data. ?How can I create a matrix-like data
> structure (data frame?) which has one column of ?real? dates (a vector of
> dates, not a factor variable) and one column of the numeric measurements?
> The strptime function converts the data into dates, but the na?ve
>
>
>
> foo <- read.table(?) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # foo is a 2-column
data
> frame with the first column a factor (of dates) and the second column a
> return vector
>
> foo.dates <- strptime(fool[,1], format)
>
> cbind(foo.dates, foo[,2])
>
>
>
> does not work (because foo.dates is not a vector) and produces a wrong
> dimension error:
>
>
>
> Warning message:
>
> In cbind(foo.dates, foo[,2]) :
>
> ?number of rows of result is not a multiple of vector length (arg 1)
>
>
>
> I am sure this is a very basic question on types, but I have spent hours on
> this without much luck. ?Any ideas/suggestions would be greatly welcome.
>
>
>
> Thank you in advance.
>
>
>
>
>
> Achilles Venetoulias
> Tel: (212) 988-2276
> axilleas at stanfordalumni.org
>
>
>
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>