Re: [R] simplier way to import txt time-series data

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 08 Jun 2006 - 08:09:37 EST

Try this which reads in the data as a data frame and appends a chron variable datetime:

Lines <- "YYYY MM DD HH data1 data2
2002 12 01 01 0.002 0.003"

DF <- read.table(textConnection(Lines), header = TRUE) library(chron)
DF$datetime <- with(DF, chron(paste(MM, DD, YYYY, sep = "/")) + HH/24) DF

On 6/7/06, Jan Schwanbeck <jansc@gmx.net> wrote:
> Hello much more experienced R-users,
>
> I have got a txt - file which contains data formated like this:
>
> YYYY MM DD HH data1 data2 ... data31
> 2002 12 01 01 0.002 0.003 ... 312.0
>
> The single columns are divided by at least one space.
>
> Is their an easy and fast way to make R understand that the first 4
> columns are year month day and hour to recognize it as time series data.
>
> The time series are not complete. Single hours could be missing.
>
> Thanks a lot for answering my question. I just cannot believe that it is
> a big problem for R to handle this clean format while it even imports
> data from excel-files.
>
> Greatings
>
> Jan
>
> ______________________________________________
> 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
>



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 Received on Thu Jun 08 08:14:28 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 08 Jun 2006 - 14:10:42 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.