[R] Read a Time Serie CSV

Daniel Mastropietro mastropi at uwalumni.com
Mon May 27 02:48:56 CEST 2002


Patrick,
The problem is that oecd96 is an object of class "ts", which returns NULL 
when referencing a variable by its name with $.
If you want to use the variable names for plotting, you can do:

plot(oecd96[,"gdpcausb"])

Daniel

P.S. In order to find out what could be the cause of an error in these 
cases the function 'class' may be useful, wich returns the class of a given 
object.

At 09:46 PM 26/5/2002 +0200, Patrick Hausmann wrote:
>Hi,
>
>I want to read some Times Series of GDP from OECD-Countrys.
>First I call:
> > oecd96<-ts(read.csv("oecd96.csv",header=T,sep=";"),start=1950,freq=1)
> > summary(oecd96)
>     gdpcausb        gdpcautb        gdpcbelb        gdpccanb
>  Min.   : 8567   Min.   : 4533   Min.   : 6616   Min.   : 8966
>  1st Qu.:10771   1st Qu.: 8717   1st Qu.: 9440   1st Qu.:11694
>  Median :15196   Median :14590   Median :15605   Median :17612
>  Mean   :15387   Mean   :14331   Mean   :14994   Mean   :17102
>  3rd Qu.:19145   3rd Qu.:19404   3rd Qu.:19798   3rd Qu.:22121
>  Max.   :25818   Max.   :24828   Max.   :25252   Max.   :25923
>[...]
>This is ok. But I can't plot a single variable by name.
>
> > plot(oecd96$gdpcausb)
>Error in xy.coords(x, y, xlabel, ylabel, log) :
>         x and y lengths differ
>
>This works:
>plot(oecd96[,1])
>
>What's my fault ?
>Thanks for any help,
>Patrick Hausmann

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list