Re: [R] reading in time series

From: jim holtman <jholtman_at_gmail.com>
Date: Thu, 20 Jan 2011 08:16:13 -0500

Is this what you are trying to do:

> x <- read.table(textConnection("3/23/2010 20:55, -0.106559999, -0.121454561, -0.120300002, -0.111680001,-0.122429997
+ 3/23/2010 21:25, -0.099166997, -0.114189997, -0.112879999, -0.104647976,-0.114720002"), sep = ',', as.is = TRUE)
> closeAllConnections()
> x

               V1 V2 V3 V4 V5 V6 1 3/23/2010 20:55 -0.106560 -0.1214546 -0.12030 -0.1116800 -0.12243 2 3/23/2010 21:25 -0.099167 -0.1141900 -0.11288 -0.1046480 -0.11472
> str(x)

'data.frame': 2 obs. of 6 variables:

 $ V1: chr  "3/23/2010 20:55" "3/23/2010 21:25"
 $ V2: num  -0.1066 -0.0992
 $ V3: num  -0.121 -0.114
 $ V4: num  -0.12 -0.113
 $ V5: num  -0.112 -0.105
 $ V6: num  -0.122 -0.115

> # convert to POSIXct
> x$V1 <- as.POSIXct(x$V1, format = "%m/%d/%Y %H:%M")
> x
                   V1        V2         V3       V4         V5       V6
1 2010-03-23 20:55:00 -0.106560 -0.1214546 -0.12030 -0.1116800 -0.12243 2 2010-03-23 21:25:00 -0.099167 -0.1141900 -0.11288 -0.1046480 -0.11472
> str(x)

'data.frame': 2 obs. of 6 variables:
 $ V1: POSIXct, format: "2010-03-23 20:55:00" "2010-03-23 21:25:00"
 $ V2: num  -0.1066 -0.0992
 $ V3: num  -0.121 -0.114
 $ V4: num  -0.12 -0.113
 $ V5: num  -0.112 -0.105
 $ V6: num  -0.122 -0.115

>

On Thu, Jan 20, 2011 at 3:04 AM, tluedeke <tluedeke_at_excite.com> wrote:
>
> This is causing me great consternation, and I've spent too much time
> floundering around on it.
>
> My data is in the form of columns in Excel, with the first column being in
> m/dd/yyyy hh:mm format.  The spreadsheet is complicated (headers, merged
> cells, lines w/o data); so I've tried various ways of exporting the data
> into a text file for the R processing - CSV, spaced, etc.  For example:
>
> 3/23/2010 20:55  -0.106559999  -0.121454561  -0.120300002  -0.111680001
> -0.122429997
> 3/23/2010 21:25  -0.099166997  -0.114189997  -0.112879999  -0.104647976
> -0.114720002
> .
> .
>
> - or -
>
> 3/23/2010 20:55,  -0.106559999,  -0.121454561,  -0.120300002,  -0.111680001,
> -0.122429997
> 3/23/2010 21:25,  -0.099166997,  -0.114189997,  -0.112879999,  -0.104647976,
> -0.114720002
> .
> .
>
> I can't seem to get R to recognize this data as a time/data column in
> m/dd/yyyy hh:mm format followed by columns of data.  There was a post on an
> analogous topic a couple of years ago, but none of the proposed (and quite
> complicated) solutions seemed to work for me.
>
> Anyone know how to handle this?
> --
> View this message in context: http://r.789695.n4.nabble.com/reading-in-time-series-tp3225481p3225481.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

______________________________________________
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.
Received on Thu 20 Jan 2011 - 13:18:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 20 Jan 2011 - 13:40:08 GMT.

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

list of date sections of archive