thank you all for your helpful replies to bert the problem with relation ="same" is the plotting along y axis of all categories ("samp.time") for all groups ("sites"); instead, I need to plot along y axis just the categories for each group effectively having a corresponding observation
to danny your solution with ggplot works like a charm; I will keep an eye to ggplot2 for other new charts but for some reasons now I must stick on lattice (which is also my favourite by the way) to richard result3 is close to what I need but still not exactly what Iâm aiming to; I need y axis to be plotted as categories not as a continuous scale⦠I need the result proposed by danny to be translated into lattice⦠to deepayan thank you so much, Iâll carefully consider your hint and Iâll try to make it works (but still Iâm not sure I fully understand how to do it); as long as I can get to a viable solution Iâll post it back Just for your information my effort up to now (NOT WORKING!) was pointing toward this direction: 1- new character variable from samp.time to be used later as label for the plot: test$samp.lab<-as.character(test$samp.time) 2- new factor variable with as many levels as the observations: test$samp.id <- gl(length(test$samp.time), 1) 3- new factor variable based on âsamp.timeâ but with the order of levels based on âsiteâ, something like this (I think this is the crucial point where I'm likely to fail): test$samp.time.site <- with(test, reorder(samp.time, as.numeric(site))) 4- new numeric level: nl <- as.numeric(levels(test$samp.time.site)) 5- plotting (wrong): dotplot(samp.time~conc|site, data=test, ylim=test$samp.lab[nl], 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<mbres...@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 > [[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.