[Rd] problem plotting "ts" in a data.frame

Spencer Graves spencer.graves at prodsyse.com
Tue Feb 9 23:56:42 CET 2016


Hello:


       I'm having trouble plotting an object of class "ts" that is in a 
data.frame.  I can do it with(data.frame, plot(...)) but not with 
plot(..., data.frame);  see the example below.


       This work around gets me past this problem.  However, I thought 
the R Core team might want to know about this if they don't already.


       Thanks for all your work in making R and CRAN the great tools 
that they are -- and I apologize for wasting your time if you are 
already familiar with this.


       Spencer Graves


 > y.ts <- ts(2:4, 5)
 > XY <- data.frame(x1=6:8, y1=y.ts)
 > plot(y1~x1, XY)
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In .cbind.ts(list(...), .makeNamesTs(...), dframe = dframe, union = 
FALSE) :
   non-intersecting series
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
4: In min(x) : no non-missing arguments to min; returning Inf
5: In max(x) : no non-missing arguments to max; returning -Inf
 > plot(y1, XY)
Error in plot(y1, XY) : object 'y1' not found
 > with(XY, plot(y1))
 > sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

loaded via a namespace (and not attached):
[1] tools_3.2.3



More information about the R-devel mailing list