[R] Lattice xyplot
arrayprofile at yahoo.com
Mon May 1 22:42:22 CEST 2017
Thanks all for the clarification!
From: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
To: r-help at r-project.org; Bert Gunter <bgunter.4567 at gmail.com>; array chip <arrayprofile at yahoo.com>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Monday, May 1, 2017 10:53 AM
Subject: Re: [R] Lattice xyplot
It is not a question of whether lattice "understands" the unsorted data... imagine trying to plot 4 points to form a square instead of a trend line... you would NOT want lattice to sort those points for you. That lattice leaves your data alone gives you more flexibility, even while it adds work for certain applications.
Sent from my phone. Please excuse my brevity.
On May 1, 2017 7:34:09 AM PDT, Bert Gunter <bgunter.4567 at gmail.com> wrote:
>Yes. type = "l" connects the points in the order given in the data, so
>if the x's are not already ordered, the plots will be different after
>ordering the x's.
>> x <- c(3,1,2,4,6,5)
>> y <- 11:16
>> xyplot(y~x. type = "l")
>As for why ... that's just the way it was designed. You can always
>order the data first, if you don't want this default.
>"The trouble with having an open mind is that people keep coming along
>and sticking things into it."
>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>On Sun, Apr 30, 2017 at 6:07 PM, array chip via R-help
><r-help at r-project.org> wrote:
>> Dear all, I am new to lattice, so would appreciate anyone's help on
>the questions below. I am using xyplot to plot some trend in my
>dataset. Using the example dataset attached, I am trying to plot
>variable "y" over variable "time" for each subject "id":
>> xyplot(y ~ time, data=dat, groups=id, aspect = "fill", type = c("p",
>"l"), xlab = "Time", ylab = "Y")
>> It appears that it just worked fine. But if I sort the "dat" first,
>the plot will look somewhat different!
>> dat<-dat[order(dat$id, dat$time),]xyplot(y ~ time, data=dat,
>groups=id, aspect = "fill", type = c("p", "l"), xlab = "Time", ylab =
>> Why is that? Do you need to sort the data first before using xyplot?
>Why xyplot can not understand the dataset unless it is sorted first?
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help