time series line plot: Error in plot.window(...) : invalid 'xlim' value
Hello, Sorry, I forgot the "time series" part of your question. You could use instead one of # 1. type = "l" gives a line plot plot(r_wvht ~ date, data = last, type="l") # 2. use time series object plot library(zoo) z <- zoo(last$r_wvht, order.by=last$date) plot(z) Rui Barradas Em 31-07-2012 18:27, Rui Barradas escreveu:
Hello,
You could use dput(), it's not your first post...
last <- structure(list(date = c("8/6/2008", "8/8/2008", "8/11/2008",
"8/13/2008", "8/14/2008", "8/18/2008", "8/20/2008", "8/27/2008",
"8/28/2008", "8/31/2008", "9/2/2008", "9/3/2008", "9/4/2008",
"9/5/2008", "9/8/2008", "9/11/2008", "10/12/2009", "10/14/2009",
"10/19/2009", "10/21/2009", "10/26/2009", "10/29/2009", "10/30/2009",
"11/2/2009", "11/3/2009", "11/4/2009", "11/11/2009", "11/13/2009"
), r_wvht = c(0.9766667, 0.7733333, 1.4833333, 1.5766667, 1.39,
0.78, 0.8383333, 1.77, 1.295, 2.41, 1.3166667, 1.3075, 1.39,
1.6333333, 1.2416667, 1.395, 0.8633333, 2.79, 1.0325, 1.965,
1.78, 1.5666667, 1.05, 1.4633333, 1.24, 1.0075, 1.605, 1.8475
)), .Names = c("date", "r_wvht"), class = "data.frame", row.names =
c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
"25", "26", "27", "28"))
last$date <- as.Date(last$date, format="%m/%d/%Y")
plot(r_wvht ~ date, data = last)
(You were forgetting that last$date was a character vector, not class
Date.)
Hope this helps,
Rui Barradas
Em 31-07-2012 18:02, Yolande Tra escreveu:
Hello, This should be pretty simple but I cannot get it right. Please point to the right code. Thanks.
last <- read.csv(file.path(dataDir,"plot1.csv"), as.is=T,stringsAsFactors
= FALSE)
last
date r_wvht 1 8/6/2008 0.9766667 2 8/8/2008 0.7733333 3 8/11/2008 1.4833333 4 8/13/2008 1.5766667 5 8/14/2008 1.3900000 6 8/18/2008 0.7800000 7 8/20/2008 0.8383333 8 8/27/2008 1.7700000 9 8/28/2008 1.2950000 10 8/31/2008 2.4100000 11 9/2/2008 1.3166667 12 9/3/2008 1.3075000 13 9/4/2008 1.3900000 14 9/5/2008 1.6333333 15 9/8/2008 1.2416667 16 9/11/2008 1.3950000 17 10/12/2009 0.8633333 18 10/14/2009 2.7900000 19 10/19/2009 1.0325000 20 10/21/2009 1.9650000 21 10/26/2009 1.7800000 22 10/29/2009 1.5666667 23 10/30/2009 1.0500000 24 11/2/2009 1.4633333 25 11/3/2009 1.2400000 26 11/4/2009 1.0075000 27 11/11/2009 1.6050000 28 11/13/2009 1.8475000
x<-as.vector(last$date) x
[1] "8/6/2008" "8/8/2008" "8/11/2008" "8/13/2008" "8/14/2008" "8/18/2008" "8/20/2008" "8/27/2008" [9] "8/28/2008" "8/31/2008" "9/2/2008" "9/3/2008" "9/4/2008" "9/5/2008" "9/8/2008" "9/11/2008" [17] "10/12/2009" "10/14/2009" "10/19/2009" "10/21/2009" "10/26/2009" "10/29/2009" "10/30/2009" "11/2/2009" [25] "11/3/2009" "11/4/2009" "11/11/2009" "11/13/2009"
y<-as.vector(last$r_wvht) y
[1] 0.9766667 0.7733333 1.4833333 1.5766667 1.3900000 0.7800000 0.8383333 1.7700000 1.2950000 2.4100000 [11] 1.3166667 1.3075000 1.3900000 1.6333333 1.2416667 1.3950000 0.8633333 2.7900000 1.0325000 1.9650000 [21] 1.7800000 1.5666667 1.0500000 1.4633333 1.2400000 1.0075000 1.6050000 1.8475000
plot(x,y)
Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf
plot(x,y,xlim=c("6/8/2008","11/13/2009"))
Error in plot.window(...) : invalid 'xlim' value
Y
[[alternative HTML version deleted]]
______________________________________________ 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.
______________________________________________ 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.