Dear Dr. Sarkar, When I try to run the codes, I found the following problem:
> h<- sample(1:14, 319, rep=T) > c<- sample(1:14, 608, rep=T) > n<- sample(1:14, 1140, rep=T) > vt<-c(h, c, n) > ta<-rep(c("h", "c", "n"), c(319, 608, 1140)) > > to<-data.frame(vt,ta) > library(lattice) Attaching package: 'lattice' The following object(s) are masked _by_ .GlobalEnv : panel.histogram > > > > histogram(~ vt|ta, data=to, layout=c(1,3), type = "count", + panel = function(x, breaks, ...) { + panel.histogram(x = x, breaks = breaks, ...) + hh <- hist(x, breaks = breaks, plot = FALSE) + with(hh, panel.text(x = mids, y = counts, + labels = as.character(counts), + pos = 1)) + }, + labels=TRUE, main="Histograms by target", col="skyblue") Warning messages: 1: In title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) : "data" is not a graphical parameter 2: In axis(1, ...) : "data" is not a graphical parameter 3: In axis(2, ...) : "data" is not a graphical parameter 4: In title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) : "data" is not a graphical parameter 5: In axis(1, ...) : "data" is not a graphical parameter 6: In axis(2, ...) : "data" is not a graphical parameter 7: In title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) : "data" is not a graphical parameter 8: In axis(1, ...) : "data" is not a graphical parameter 9: In axis(2, ...) : "data" is not a graphical parameter > searchpaths() [1] ".GlobalEnv" "/home/cdu/library/lattice" [3] "/home/cdu/library/stats" "/home/cdu/library/graphics" [5] "/home/cdu/library/grDevices" "/home/cdu/library/utils" [7] "/home/cdu/library/datasets" "/home/cdu/library/methods" [9] "Autoloads" Do you have any suggestions for this problem? Thanks so much! On Fri, Apr 23, 2010 at 5:45 AM, Deepayan Sarkar < deepayan.sar...@r-project.org> wrote: > On Tue, Apr 20, 2010 at 8:59 AM, Changbin Du <changb...@gmail.com> wrote: > > HI, Dear Deepayan, > > > > I am using the following codes to get the conditional histogram, can I > label > > the values on each bar? > > Thanks so much! > > > > h<- sample(1:14, 319, rep=T) > > c<- sample(1:14, 608, rep=T) > > n<- sample(1:14, 1140, rep=T) > > vt<-c(h, c, n) > > ta<-rep(c("h", "c", "n"), c(319, 608, 1140)) > > > > to<-data.frame(vt,ta) > > > > library(lattice) > > histogram(~ vt|ta, data=to, layout=c(1,3), labels=TRUE, main="Histograms > by > > target", col="skyblue") > > You have to write a custom panel function. Here's one example: > > histogram(~ vt|ta, data=to, layout=c(1,3), type = "count", > panel = function(x, breaks, ...) { > panel.histogram(x = x, breaks = breaks, ...) > hh <- hist(x, breaks = breaks, plot = FALSE) > with(hh, panel.text(x = mids, y = counts, > labels = as.character(counts), > pos = 1)) > }, > labels=TRUE, main="Histograms by target", col="skyblue") > > The function may need to be more complicated depending on what you need. > > -Deepayan > -- Sincerely, Changbin -- [[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.