Thank you, Mike! On 5/3/07, Michael Sumner <[EMAIL PROTECTED]> wrote: > > Hello, > > It seems that "danish" is a numeric vector with attributes attached - > the attribute vector is POSIXct and is the same length as danish. > > You can create this from a data frame like this: > > x <- data.frame(Date = ISOdate(2007, 5, 1:10), Value = rnorm(10)) > str(x) > 'data.frame': 10 obs. of 2 variables: > $ Date :'POSIXct', format: chr "2007-05-01 12:00:00" "2007-05-02 > 12:00:00" "2007-05-03 12:00:00" "2007-05-04 12:00:00" ... > $ Value: num 1.891 0.741 -0.368 1.701 -0.660 ... > > xx <- x$Value > attr(xx, "times") <- x$Date > str(xx) > atomic [1:10] 0.0414 -0.7124 -1.2976 0.3101 0.4343 ... > - attr(*, "times")='POSIXct', format: chr [1:10] "2007-05-01 12:00:00" > "2007-05-02 12:00:00" "2007-05-03 12:00:00" "2007-05-04 12:00:00" ... > > > HTH > > Cheers, Mike. > > > Dear List: > > > > I have a simple two-column data set in .csv format, with the first > column > > being the date and second column being some value. I use read.csv() to > > import the data as follows: > > > > > > > > x <- read.csv("myfile.csv",header=T, dec=".", > colClasses=c(Date="POSIXct")) > > > > > > > > The structure of x is: > > > > > > > > > str(x) > > > > `data.frame': 2959 obs. of 2 variables: > > > > $ Date:'POSIXct', format: chr "1998-01-01" "1998-01-01" "1998-01-01" > > "1998-01-01" ... > > > > $ Value: num 0.07379 0.07181 0.01555 0.00630 0.00688 ... > > > > > > > > This is not what I want. Instead, I want the structure to be the same > as > > that of the following data set: > > > > > > > > > str(danish) > > > > atomic [1:2167] 1.68 2.09 1.73 1.78 4.61 ... > > > > - attr(*, "times")='POSIXct', format: chr [1:2167] "1980-01-02 > 18:00:00" > > "1980-01-03 18:00:00" "1980-01-04 18:00:00" "1980-01-06 18:00:00" ... > > > > > > > > "danish" is a data set that the package "evir" comes with. > > > > > > Any help would be appreciated. > > > > [[alternative HTML version deleted]] > > > > > > >
[[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.