It does look better indeed. Thanks,

Yolande

On Tue, Jul 31, 2012 at 3:15 PM, Rui Barradas <ruipbarra...@sapo.pt> wrote:

> Hello,
>
> Adapted from the help page for plot.zoo
>
> #library(zoo)
> #z <- zoo(last$r_wvht, order.by=last$date)
> plot(z, xaxt = "n")
> tt <- time(z)
> ix <- seq(1, length(tt), length.out=8)
> axis(side = 1, at = tt[ix], labels = FALSE)
> labs <- format(tt, "%Y-%b-%d")
> axis(side = 1, at = tt[ix], labels = labs[ix], tcl = -0.7, cex.axis = 0.7,
> las=2)
>
>
> It looks better, but I wouldn't risk "good".
>
> Rui Barradas
>
> Em 31-07-2012 19:10, Yolande Tra escreveu:
>
>>  Thanks.
>> This is an irregular time series. The line plot does not look good because
>> of the gap between 9/11/2008 and 10/12/2009. I think two plots would be
>> better.
>> How would you include the date on the x-axis. Right now it only gives one
>> tick mark, 2009.
>>
>> Yolande
>>
>> On Tue, Jul 31, 2012 at 2:01 PM, Rui Barradas <ruipbarra...@sapo.pt>
>> wrote:
>>
>>  Hello,
>>>
>>> It only gives that error if you don't
>>>
>>>
>>> last$date <- as.Date(last$date, format="%m/%d/%Y")
>>>
>>> You must have dates, not character values.
>>> Try it, then make a zoo object, then plot it.
>>>
>>> Rui Barradas
>>>
>>> Em 31-07-2012 18:54, Yolande Tra escreveu:
>>>
>>>   Thank you everyone for the attempt to solve the problem
>>>
>>>>  It is an irregular series and insert NAs when a date is missing
>>>>
>>>> library(zoo)
>>>>> z <- zoo(last$r_wvht, order.by=last$date)
>>>>> plot(z)
>>>>>
>>>>> 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
>>>>
>>>> I have also tried
>>>>
>>>> z <- read.zoo("plot1.csv", header = TRUE, sep = ",", format =
>>>> "%m/%d/%Y")
>>>>
>>>>> plot(z)
>>>>>
>>>>> The plot does not look good. It does not display the individual dates.
>>>>
>>>> Y
>>>> Y
>>>> On Tue, Jul 31, 2012 at 1:33 PM, Rui Barradas <ruipbarra...@sapo.pt>
>>>> wrote:
>>>>
>>>>   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@r-project.org mailing list
>>>>>>> https://stat.ethz.ch/mailman/******listinfo/r-help<https://stat.ethz.ch/mailman/****listinfo/r-help>
>>>>>>> <https://**stat.ethz.ch/mailman/****listinfo/r-help<https://stat.ethz.ch/mailman/**listinfo/r-help>
>>>>>>> >
>>>>>>> <https://stat.**ethz.ch/**mailman/listinfo/r-**help<http://ethz.ch/mailman/listinfo/r-**help>
>>>>>>> <http**s://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>>>>>> >
>>>>>>> PLEASE do read the posting guide 
>>>>>>> http://www.R-project.org/**<http://www.r-project.org/**>
>>>>>>> <ht**tp://www.r-project.org/** <http://www.r-project.org/**>>
>>>>>>> posting-guide.html 
>>>>>>> <http://www.r-project.org/****posting-guide.html<http://www.r-project.org/**posting-guide.html>
>>>>>>> <http://www.**r-project.org/posting-guide.**html<http://www.r-project.org/posting-guide.html>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>>>
>>>>>>> ______________________________******________________
>>>>>>>
>>>>>> R-help@r-project.org mailing list
>>>>>> https://stat.ethz.ch/mailman/******listinfo/r-help<https://stat.ethz.ch/mailman/****listinfo/r-help>
>>>>>> <https://**stat.ethz.ch/mailman/****listinfo/r-help<https://stat.ethz.ch/mailman/**listinfo/r-help>
>>>>>> >
>>>>>> <https://stat.**ethz.ch/**mailman/listinfo/r-**help<http://ethz.ch/mailman/listinfo/r-**help>
>>>>>> <http**s://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>>>>> >
>>>>>> PLEASE do read the posting guide 
>>>>>> http://www.R-project.org/**<http://www.r-project.org/**>
>>>>>> <ht**tp://www.r-project.org/** <http://www.r-project.org/**>>
>>>>>> posting-guide.html 
>>>>>> <http://www.r-project.org/****posting-guide.html<http://www.r-project.org/**posting-guide.html>
>>>>>> <http://www.**r-project.org/posting-guide.**html<http://www.r-project.org/posting-guide.html>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>>
>>>>>>
>>>>>>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to