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 ------------- Patrick Hausmann Friedrich-Wilhelm Str. 37 - D-28199 Bremen Tel. +49 421 5980631 - Fax. +49 421 5980632 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > 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 ?only data.frame and list objects can use the "$" notation for subelements. You can still use names, however. plot(oecd96[,"gdpcausb"]) should work. Check out "An Introduction to R", which is distributed with R as the file "R-intro.pdf". This is nicely explained in the chapters "Arrays and Matricies" and "Lists and data frames". Cheers Jason -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, I have used the scan() function to read data from a file as follows: x <- scan("myfile", as.list(c(rep("", times = 9), class="", rep("", times = 3))), comment.char="") This reads in all the 13 fields. These 13 fields are enumerated or user defined datatypes. I guess they are called factors in this context although I dont know what exactly they are or are for. Now I tried to use the lm() function to fit a linear model as follows: y <- lm(x$class ~ ., x) But this is the error message I am getting: Error in eval(expr, envir, enclos) : Object "c..1....1....1....1....1....2....2....2....2....3....3....3..." not found I looked at the lm() function code but could not find any eval() function in it. My guess is that the problem occurs because none of the variables (either response or otherwise) are numeric, they are all user defined. Can someone help by telling me how to fit a linear model to these "non-numeric" fields or otherwise explain what the problem could be. Thanks in advance. -Saket. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._