Skip to content
Prev 301858 / 398506 Next

time series line plot: Error in plot.window(...) : invalid 'xlim' value

On Tue, Jul 31, 2012 at 12:02 PM, Yolande Tra <yolande.tra at gmail.com> wrote:
Here's your problem -- "x" is all strings so you can't make an x-axis
out of them later. I'll show you how to diagnose that below. You
probably want as.Date() here -- I rarely (never?) have occasion to use
as.vector().
Taking these in order --

1) we see something had to be coerced: I know it was the strings above
and all of them created NA's because they weren't numeric literals.
2) Since all our arguments were NA to min, we have no information
about the min() and return Inf.
3) Ibid, returning -Inf.

giving in turn the error:

x limits from -Inf to Inf don't make a well defined graph.

Big picture, you should probably use a zoo object here instead of a
data frame and awkward column conversion:

library(zoo)
x <- read.zoo( file_path) # Creates a "zoo" object x

plot(x) # Will use the index of x automatically as the x axis and the
values as the y because x is a zoo (read time series) object.

and it should all happen magically.

Michael