I debated saying something similar but decided not to, as polygons can
be drawn e.g. via panel.polygon.
Cheers,
Bert
On Mon, May 1, 2017 at 8:25 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
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.
e.g.
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.
Cheers,
Bert
Bert Gunter
"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":
dat<-read.table("dat.txt",sep='\t',header=T,row.names=NULL)
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 =
"Y")
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?