my reproducible example
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
dotplot(samp.time~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
my objective is to use ?site? as conditioning variable but with ?samp.time?
correctly grouped by ?site?; the problem here is to ensure that levels of
?samp.time? within each ?site? are contiguous as otherwise they would be not
contiguous in the dot plot itself (i.e, avoid that sort of holes in between
y axis categories -see dotplot -)
I?ve been trying with this but without much success
test$samp.time.new<-
with(test,reorder(samp.time,as.numeric(site)))
dotplot(samp.time.new~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
I think (I hope) a possible different solution is to create for "ylim" a
proper character vector of different length to pass to each panel of the
dotplot (I?m not posting this attempt because too much confused up to now)
can anyone point me in the right direction?
any help much appreciated
thank you
--
View this message in context: http://r.789695.n4.nabble.com/lattice-dotplot-reorder-contiguous-levels-tp4643741.html
Sent from the R help mailing list archive at Nabble.com.
lattice dotplot reorder contiguous levels
8 messages · Bert Gunter, Richard M. Heiberger, Deepayan Sarkar +1 more
I don't entirely understand what you want as an alternative. What is wrong with relation ="same", the default? In any case, it sounds like you'll need to write your own panel function. If you look at panel.dotplot(), you'll see it's fairly straightforward, so modification should not be difficult. BTW, thanks for the reproducible example. I wouldn't have bothered at all without it, although maybe the result is the same so far as your concerned. Cheers, Bert
On Thu, Sep 20, 2012 at 7:18 AM, maxbre <mbressan at arpa.veneto.it> wrote:
my reproducible example
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
dotplot(samp.time~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "same")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
my objective is to use ?site? as conditioning variable but with ?samp.time?
correctly grouped by ?site?; the problem here is to ensure that levels of
?samp.time? within each ?site? are contiguous as otherwise they would be not
contiguous in the dot plot itself (i.e, avoid that sort of holes in between
y axis categories -see dotplot -)
I?ve been trying with this but without much success
test$samp.time.new<-
with(test,reorder(samp.time,as.numeric(site)))
dotplot(samp.time.new~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
I think (I hope) a possible different solution is to create for "ylim" a
proper character vector of different length to pass to each panel of the
dotplot (I?m not posting this attempt because too much confused up to now)
can anyone point me in the right direction?
any help much appreciated
thank you
--
View this message in context: http://r.789695.n4.nabble.com/lattice-dotplot-reorder-contiguous-levels-tp4643741.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Is result3 what you are looking for?
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
result0 <-
dotplot(samp.time~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
result0
test$sample.time <- as.numeric(as.character(test$samp.time))
result1 <-
xyplot(sample.time ~ conc | site,
data=test,
scales=list(x=list(log=10), y = list(relation = "same")),
layout=c(1,5), strip=FALSE, strip.left=TRUE,
panel=panel.dotplot)
result1
result2 <-
update(result1, panel=function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.rug(y=y)
}
)
result2
trellis.par.get("superpose.line")
new.col <- c(trellis.par.get("superpose.line")$col, "darkgreen", "darkblue")
trellis.par.set(superpose.line=list(col=new.col),
superpose.symbol=list(col=new.col))
result3 <-
xyplot(sample.time ~ conc | site,
groups=samp.time, pch=16,
data=test,
scales=list(x=list(log=10), y = list(relation =
"same"), alternating=1),
layout=c(1,5), strip=FALSE, strip.left=TRUE,
par.settings = list(clip = list(panel = "off")),
panel=function(x, y, ...) {
panel.xyplot(x, y, ...)
gg <- list(...)$groups
subs <- list(...)$subscripts
col=trellis.par.get("superpose.line")$col
panel.rug(y=unique(y),
col=unique(col[match(gg[subs], levels(gg))]))
for (uy in unique(y))
panel.axis(side="right", at=uy, outside=TRUE,
text.col=col[match(uy, levels(gg))],
line.col=col[match(uy, levels(gg))])
}
)
result3
On 9/20/12, maxbre <mbressan at arpa.veneto.it> wrote:
my reproducible example
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
dotplot(samp.time~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
my objective is to use ?site? as conditioning variable but with ?samp.time?
correctly grouped by ?site?; the problem here is to ensure that levels of
?samp.time? within each ?site? are contiguous as otherwise they would be not
contiguous in the dot plot itself (i.e, avoid that sort of holes in between
y axis categories -see dotplot -)
I?ve been trying with this but without much success
test$samp.time.new<-
with(test,reorder(samp.time,as.numeric(site)))
dotplot(samp.time.new~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
I think (I hope) a possible different solution is to create for "ylim" a
proper character vector of different length to pass to each panel of the
dotplot (I?m not posting this attempt because too much confused up to now)
can anyone point me in the right direction?
any help much appreciated
thank you
--
View this message in context:
http://r.789695.n4.nabble.com/lattice-dotplot-reorder-contiguous-levels-tp4643741.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
On Thu, Sep 20, 2012 at 7:48 PM, maxbre <mbressan at arpa.veneto.it> wrote:
my reproducible example
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
dotplot(samp.time~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
my objective is to use ?site? as conditioning variable but with ?samp.time?
correctly grouped by ?site?; the problem here is to ensure that levels of
?samp.time? within each ?site? are contiguous as otherwise they would be not
contiguous in the dot plot itself (i.e, avoid that sort of holes in between
y axis categories -see dotplot -)
I?ve been trying with this but without much success
test$samp.time.new<-
with(test,reorder(samp.time,as.numeric(site)))
dotplot(samp.time.new~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
I think (I hope) a possible different solution is to create for "ylim" a
proper character vector of different length to pass to each panel of the
dotplot (I?m not posting this attempt because too much confused up to now)
can anyone point me in the right direction?
The problem here is that there is crossing between sites and
samp.time. You can try some imaginative permutations of site, such as
test$samp.time.new <- with(test, reorder(samp.time,
as.numeric(factor(site, levels = c("A", "C", "D", "B", "E")))))
which gets all but site B right. There may be another permutation that
works for everything, but it would be much easier to make a nested
factor, i.e.,
test$samp.time.new <- with(test, reorder(samp.time:site, as.numeric(site)))
That just leaves getting the y-labels right, which I will leave for
you to figure out.
(Hint: ylim = some_function_of(levels(test$samp.time.new)))
-Deepayan
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120921/98992edc/attachment.pl>
deepayan, is that what you mean?
but still the problem persists: nor correct neither contiguous labelling!
I must probably reconsider everything from scratch: I'm bit confused now...
test$samp.time.new <- with(test, reorder(samp.time:site, as.numeric(site)))
s<-strsplit(levels(test$samp.time.new), ":")
s1<- sapply(s, '[', 1)
dotplot(samp.time~conc|site, data=test,
ylim=s1,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
Il 21/09/2012 08:55, Deepayan Sarkar ha scritto:
On Thu, Sep 20, 2012 at 7:48 PM, maxbre <mbressan at arpa.veneto.it> wrote:
my reproducible example
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
dotplot(samp.time~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
my objective is to use ?site? as conditioning variable but with ?samp.time?
correctly grouped by ?site?; the problem here is to ensure that levels of
?samp.time? within each ?site? are contiguous as otherwise they would be not
contiguous in the dot plot itself (i.e, avoid that sort of holes in between
y axis categories -see dotplot -)
I?ve been trying with this but without much success
test$samp.time.new<-
with(test,reorder(samp.time,as.numeric(site)))
dotplot(samp.time.new~conc|site, data=test,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
I think (I hope) a possible different solution is to create for "ylim" a
proper character vector of different length to pass to each panel of the
dotplot (I?m not posting this attempt because too much confused up to now)
can anyone point me in the right direction?
The problem here is that there is crossing between sites and
samp.time. You can try some imaginative permutations of site, such as
test$samp.time.new <- with(test, reorder(samp.time,
as.numeric(factor(site, levels = c("A", "C", "D", "B", "E")))))
which gets all but site B right. There may be another permutation that
works for everything, but it would be much easier to make a nested
factor, i.e.,
test$samp.time.new <- with(test, reorder(samp.time:site, as.numeric(site)))
That just leaves getting the y-labels right, which I will leave for
you to figure out.
(Hint: ylim = some_function_of(levels(test$samp.time.new)))
-Deepayan
5 days later
sorry for my slow reply, this is what I worked out so far?
my reproducible example and the code
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
test$samp.time.new <- with(test, reorder(samp.time:site, as.numeric(site)))
m<-match(unique(droplevels(test$samp.time.new)),test$samp.time.new)
lab<-as.character(test$samp.time[m])
dotplot(samp.time.new~conc|site, data=test,
ylim=lab,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
Now labels are correctly spaced and sorted out but still a ?slight? problem
persist: i.e. the reordering of samp.time.new within each site; in fact, I
would like to have an ascending order of sampling time but for some reason
I?m not able to work it out properly?
any help much appreciated
max
--
View this message in context: http://r.789695.n4.nabble.com/lattice-dotplot-reorder-contiguous-levels-tp4643741p4644215.html
Sent from the R help mailing list archive at Nabble.com.
On Wed, Sep 26, 2012 at 3:36 PM, maxbre <mbressan at arpa.veneto.it> wrote:
sorry for my slow reply, this is what I worked out so far?
my reproducible example and the code
test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")
test$samp.time.new <- with(test, reorder(samp.time:site, as.numeric(site)))
m<-match(unique(droplevels(test$samp.time.new)),test$samp.time.new)
lab<-as.character(test$samp.time[m])
dotplot(samp.time.new~conc|site, data=test,
ylim=lab,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
Now labels are correctly spaced and sorted out but still a ?slight? problem
persist: i.e. the reordering of samp.time.new within each site; in fact, I
would like to have an ascending order of sampling time but for some reason
I?m not able to work it out properly?
For that, it should be enough to just reorder again by samp.time. Your
label code doesn't work then (I haven't tried to figure out why), but
your earlier idea using strsplit() does:
test$samp.time.new <-
with(test, reorder(reorder(samp.time:site, as.numeric(site)),
as.numeric(samp.time)))
lab <- sapply(strsplit(levels(test$samp.time.new), ":", fixed=TRUE), "[", 1)
dotplot(samp.time.new~conc|site, data=test,
ylim=lab,
scales=list(x=list(log=10), y = list(relation = "free")),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)
-Deepayan