Re: [R] Different x-axis scales using c() in latticeExtra
latticeExtra's c() can not combine logarithmic with linear x scales, I'm afraid. I would recommend displaying each separate plot on one page using plot.trellis() or the gridExtra function that John Kane mentioned. Cheers Felix On 21 July 2013 02:50, David Winsemius dwinsem...@comcast.net wrote: On Jul 19, 2013, at 8:18 PM, Jeff Stevens wrote: Hi, I would like to combine multiple xyplots into a single, multipanel display. Using R 3.0.1 in Ubuntu, I have used c() from latticeExtra to combine three plots, but the x-axis for two plots are on a log scale and the other is on a normal scale. I also have included equispace.log=FALSE to clean up the tick labels. However, when I try all of these, the x-axis scale of the first panel is used for all three. How do I keep different scales for the different panels? Here is an example: library(lattice) library(latticeExtra) response - c(76, 14, 15, 44, 26, 19, 74, 123, 49, 8, 56, 17, 18) predictor1 - c(107, 7, 25, 501, 64, 88, 344, 367, 379, 10, 66, 31, 32) predictor2 - c(10, 9, 8, 10, 29, 27, 55, 48, 2, 6, 14, 10, 5) predictor3 - c(67, 22, 66, 41, 72, 64, 69, 63, 64, 70, 60, 75, 78) pred1_plot - xyplot(response ~ predictor1, scales = list(log = TRUE, equispaced.log = FALSE), panel = function(x, y, ...) { panel.xyplot(x, y, type = c(p, r), cex = 2) panel.text(x = log10(8), y = log10(120), labels = (a)) } ) pred2_plot - xyplot(response ~ predictor2, scales = list(log = TRUE, equispaced.log = FALSE), panel = function(x, y, ...) { panel.xyplot(x, y, type = c(p, r), cex = 2) panel.text(x = log10(2), y = log10(120), labels = (b)) } ) pred3_plot - xyplot(response ~ predictor3, scales = list(y = list(log = TRUE, equispaced.log = FALSE)), panel = function(x, y, ...) { panel.xyplot(x, y, type = c(p, r), cex = 2) panel.text(x = 22, y = log10(120), labels = (c)) } ) all_plots - c(pred1_plot, pred2_plot, pred3_plot, layout = c(3, 1), x.same = F) update(all_plots, xlab=c(Predictor 1,Predictor 2, Predictor 3), scales = list(y=list(log=T, equispaced.log=FALSE), x = c(list(log=T, equispaced.log=FALSE), list(log=T, equispaced.log=FALSE), list(log=F update(all_plots, xlab=c(Predictor 1,Predictor 2, Predictor 3), scales = c(list(log = TRUE, equispaced.log = FALSE), list(log = TRUE, equispaced.log = FALSE), list(y=list(log=T, equispaced.log = FALSE Any help is appreciated! I assume there was a notice o your console that there were warnings, right? You should offer the full texts of warnings and error messages. Here the full text of the first and second warnings: warnings()[1:2] $`log scales cannot be changed via 'update'` update.trellis(all_plots, xlab = c(Predictor 1, Predictor 2, Predictor 3), scales = c(list(log = TRUE, equispaced.log = FALSE), list(log = TRUE, equispaced.log = FALSE), list(y = list(log = T, equispaced.log = FALSE $`'x' is NULL so the result will be NULL` rep(scales[[nm]], length.out = 2) The first one is telling you why the results should be different than you expect. I'm not entirely sure what the second one is telling you, but it doesn't sound good. -- David Winsemius Alameda, CA, USA __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] [lattice] display a projected map on a layerplot
* draw a map, while the code above does not. How to fix? TIA, Tom Roche tom_ro...@pobox.com roche@epa.gov ---original example follows to end of post--- # Following adapted from what is installed in my # .../R/x86_64-pc-linux-gnu-library/2.14/m3AqfigExampleScript.r # (probably by my sysadmin), which also greatly resembles # https://wiki.epa.gov/amad/index.php/R_packages_developed_in_AMAD # which is behind a firewall :-( ## EXAMPLE WITH LAMBERT CONIC CONFORMAL FILE. library(M3) library(aqfig) # http://cran.r-project.org/web/packages/aqfig/ ## Use an example file with LCC projection: either local download ... lcc.file - ./ozone_lcc.nc ## ... or as installed by package=M3: # lcc.file - system.file(extdata/ozone_lcc.ncf, package=M3) ## Choose the one that works for you. ## READ AND PLOT OZONE FROM FILE WITH LCC PROJECTION. ## Read in variable with daily ozone. Note that we can give dates ## rather than date-times, and that will include all time steps ## anytime during those days. Or, we can give lower and upper bounds ## and all time steps between these will be taken. o3 - M3::get.M3.var( file=lcc.file, var=O3, ldatetime=as.Date(2001-07-01), udatetime=as.Date(2001-07-04)) ## Get colors and map boundaries for plot. library(fields) col.rng - tim.colors(20) detach(package:fields) ## Get state boundaries in projetion units. map.lines - M3::get.map.lines.M3.proj(file=lcc.file, database=state) ## Set color boundaries so that they incorporate the complete data range. z.rng - range(as.vector(o3$data)) ## Make a color tile plot of the ozone for the first day (2001-07-01). image(o3$x.cell.ctr, o3$y.cell.ctr, o3$data[,,1,1], col=col.rng, zlim=z.rng, xlab=Projection x-coord (km), ylab=Projection y-coord (km)) ## Put date-time string and chemical name (O3) into a format I can use ## to label the actual figure. date.str - format(o3$datetime[1], %Y-%m-%d) title(main=bquote(paste(O[3], on , .(date.str), sep=))) ## Put the state boundaries on the plot. lines(map.lines$coords) ## Add color bar to the right of plot to show what colors go with what ## ozone concentraton. NOTE: AFTER USING vertical.image.legend(), YOU ## WON'T BE ABLE TO ADD NEW FEATURES TO THE PLOT. Before making a new ## plot, you should open a new device or turn this device off. vertical.image.legend(zlim=z.rng, col=col.rng) dev.off() # close the plot if you haven't already __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] Help: stemming and stem completion with package tm in R
Hi Yanchang, The problem seems to be that stemCompletion only looks for words that begin with mine, and mining does not strictly begin with mine. I don't think there is any easy way to modify stemCompletion to get around that. However, maybe you could substitute the most prevalent word in your document for each of the stemmed words, then you would not need to use stemCompletion at all: e.g. topfreq - function(x) rev(names(sort(table(x[1] (d - ave(a, b, FUN = topfreq)) # [1] mining miners mining Cheers Felix On 4 November 2011 12:28, Yanchang Zhao yanchangz...@gmail.com wrote: Hi All I came across a problem below when doing stemming and stem completion with package tm in R. Word mining was stemmed to mine with stemDocument(), and then completed to minerswith stemCompletion(). However, I prefer to keep mining intact. For stemCompletion(), the default type of completion is prevalent, which takes the most frequent match as completion. Although mining is much more frequent than miners in my text, it still completed mine to miners. An example is shown below. library(tm) (a - c(mining, miners, mining)) (b - stemDocument(a)) (d - stemCompletion(b, dictionary=a)) Some possible solutions are: 1) to change the options or dictionary in stemDocument(), so that mining is not stemmed to mine, which I think is the best way; 2) to change the options or dictionary in stemCompletion(), so that mine is completed to mining; 3) to manually correct this after stem completion, which is the last option. I am looking for a solution for above 1) or 2), but cannot find the way to do it with stemDocument() in package tm. Any help will be appreciated. Thanks, Yanchang Zhao Email: yanchangzhao(at)gmail.com RDataMining: http://www.rdatamining.com Twitter: http://twitter.com/RDataMining Group on Linkedin: http://group2.rdatamining.com [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] Coloring Dirichlet Tiles
On 5 September 2011 06:59, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Try this, d - data.frame(x=runif(1e3, 0, 30), y=runif(1e3, 0, 30)) d$z = (d$x - 15)^2 + (d$y - 15)^2 library(spatstat) library(maptools) W - ripras(df, shape=rectangle) W - owin(c(0, 30), c(0, 30)) X - as.ppp(d, W=W) Y - dirichlet(X) Z - as(Y, SpatialPolygons) plot(Z, col=grey(d$z/max(d$z))) and also panel.voronoi in latticeExtra. Unfortunately I do not know of a solution that uses more efficient algorithms for computing the Dirichlet tessellation and extracting tiles than those relying on deldir. The Triangle package (r-forge) looks promising. panel.voronoi() can use either deldir or tripack. tripack is non-free but is much faster. xyz - data.frame(x = rnorm(1000), y = rnorm(1000), z = rnorm(1000)) library(latticeExtra) system.time(print(tileplot(z ~ x * y, xyz))) ## deldir by default # user system elapsed # 3.636 0.004 3.651 system.time(print(tileplot(z ~ x * y, xyz, use.tripack = TRUE))) # user system elapsed # 1.176 0.000 1.359 HTH, baptiste On 5 September 2011 06:26, awesolow aweso...@andrew.cmu.edu wrote: Hi, I have a set of x, y points (longitude/latitude) along with a z value representing an attribute at each point. I want to create a Voronoi/Dirichlet tesselation of these points coloring each tile by the z value. I tried searching for a way to solve this and it was suggested to use the dirichlet() command to get the correct coloring. However, my coloring is not correct. Any thoughts? Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/Coloring-Dirichlet-Tiles-tp3789746p3789746.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] Constructing an additional key inside of a lattice panel
'corner' is not a valid name for a component of 'legend'. See ?xyplot Try xyplot(1 ~ 1, legend = list(inside = list(fun=draw.key, args = list( key = list( text = list(month.name[1:2]), lines = list(lty = 1:2) ), draw = TRUE ), corner = c(0, .98) ) ) ) On 18 August 2011 21:05, Fredrik Karlsson dargo...@gmail.com wrote: Dear Deepayan, Thank you for your quick and enlightening reply. I'll try making a modifies version of the two functions and see what I end up with.. However, out of pure curiosity, what is wrong with the legend I constructed below: legend=list(corner=list( fun=draw.key, args=list( key=list(text= list(myFactorLevels), lines=list( lty=1:length(myFactorLevels)) ), draw=TRUE ) ),x=0,y=1 It gives me nothing (not even an error message :-)), so I have no idea about what I did wrong here. I would very much appreciate any insight on this. /Fredrik On Wed, Aug 17, 2011 at 2:57 PM, Deepayan Sarkar deepayan.sar...@gmail.comwrote: On Tue, Aug 16, 2011 at 4:35 PM, Fredrik Karlsson dargo...@gmail.com wrote: Hi, I would like to add an additional key inside of a panel based on a factor that is not the groups argument. I've tried using the panel.key function in latticeExtras, but I cannot get the line types the way I want it. Using my factor myGroups, I've tried this: panel.key(text=levels(myGroups),lines=TRUE,points=FALSE,corner = c(0,.98),key=list(lines=list(lty=1:length(levels(myGroups) I then get the key where I want it, the text is right, but line types are not correct (always lty=1, I think). Any ideas on how I could solve this? Well, trying to add undocumented arguments and hoping they will magically work usually doesn't help. panel.key() works using simpleKey(), which by design is simple but not flexible. In particular, it will not allow you to set 'lty' directly, and instead use the values from the theme currently in use. You _can_ change the theme also, using a different argument; e.g., library(lattice) library(latticeExtra) xyplot(1 ~ 1, panel = function(...) { panel.xyplot(...) panel.key(text = month.name[1:2],lines=TRUE,points=FALSE, corner = c(0,.98)) }, par.settings = simpleTheme(lty = 1:2)) But I don't know if that interferes with the rest of your call. If all else fails, panel.key() is not a very complicated function, so you can take inspiration from it and write your own version that replaces the line key - simpleKey(text, ...) with key - something else where something else describes the legend that you want. -Deepayan -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] Any alternatives to draw.colorkey from lattice package?
You can just specify the label positions, you don't need to give labels for every color change point: (there is an 'at' for the color changes and a 'labels$at' for the labels) levelplot(rnorm(100) ~ x * y, expand.grid(x = 1:10, y = 1:10), colorkey = list(at = seq(-3,3,length=100), labels = list(labels = paste(-3:3, units), at = -3:3))) On 13 August 2011 19:59, Jim Lemon j...@bitwrit.com.au wrote: On 08/13/2011 04:34 AM, Mikhail Titov wrote: Hello! I’d like to have a continuous color bar on my lattice xyplot with colors lets say from topo.colors such that it has ticks labels at few specific points only. Right now I use do.breaks level.colors with somewhat large number of steps. The problem is that color change point doesn’t necessary correspond to the value I’d like to label. Since I have many color steps and I don’t need high precision I generate labels like this labels- ifelse( sapply(at,function(x) any(abs(att-x).03)) , sprintf(depth= %s ft, at), ) , where `att` has mine points of interest on color scale bar and `at` corresponds to color change points used with level.colors . It is a bit inconvenient as I have to adjust threshold `.03`, number of color steps so that it labels only adjacent color change point with my labels. Q: Are there any ready to use functions that would generate some kind of GRaphical OBject with continuous color scale bar/key with custom at/labels such that it would work with `legend` argument of xyplot from lattice? Hi Mikhail, I think that color.legend in the plotrix package will do what you are asking, but it is in base graphics, and may not work with lattice. Jim __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] Passing on groups argument to xyplot within a plotting function
The problem is that xyplot tries to evaluate 'groups' in 'data' or in the formula environment. Your local function environment (where the variable named groups is defined) is neither of these. There are a couple of ways to get the evaluation to work out; here is one: pb - list(F1 = 1:8, F2 = 1:8, Type = c('a','a','a','a','b','b','b','b')) foo - function(x,data,groups, ...){ ccall - quote(xyplot(x,data=data, ...)) ccall$groups - substitute(groups) eval(ccall) } foo(F1 ~ F2, pb, groups = Type) Hope that helps -Felix On 11 August 2011 19:42, Fredrik Karlsson dargo...@gmail.com wrote: Hi, I am constructing a plotting function that I would like to behave like plotting functions within the lattice package. It takes a groups argument, which I process, and then I would like to pass that argument on to the xyplot function for the actual plotting. However, what ever I do, get an error that the variable is missing. A short illustration: Given the data set names(pb) [1] Type Sex Speaker Vowel IPA F0 F1 [8] F2 F3 and these test functions: TESTFUN - function(x,data,groups){ xyplot(x,data=data,groups=groups) } TESTFUN2 - function(x,data,groups){ xyplot(x,data=data,groups=substitute(groups)) } TESTFUN3 - function(x,data,groups){ groups - eval(substitute(groups), data, environment(x)) xyplot(x,data=data,groups=groups) } I fail to get groups to be passed on to xyplot correctly: TESTFUN(F1 ~ F2,data=pb,groups=Type) Error in eval(expr, envir, enclos) : object 'groups' not found TESTFUN2(F1 ~ F2,data=pb,groups=Type) Error in prepanel.default.function(groups = groups, x = c(2280L, 2400L, : object 'groups' not found TESTFUN3(F1 ~ F2,data=pb,groups=Type) Error in eval(expr, envir, enclos) : object 'groups' not found Please help me understand what I am doing wrong. /Fredrik -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] panel.loess confidence interval
On 6 June 2011 06:45, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Jun 5, 2011 at 3:18 PM, Mark Ebbert mark.ebb...@hci.utah.edu wrote: Dear R gurus, Based on my searches I think I know the answer to this question, but I'd like to pose it to you. Is there an easy way to plot the confidence interval around a loess line using lattice? The only thing I've found is ggplot, but I prefer to stick with lattice out of preference. See segplot in latticeExtra panel.smoother() in latticeExtra is probably what you are after, it is based on stat_smooth() from ggplot2. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] ylab spacing in resizePanels in latticeExtra
Indeed, ylab position is not connected to the panel size / position. You would have to place them manually... ## scaling factors on panels h - c(5,3,4) update(ABCur, ylab = list(c(AAA, BBB, CCC), rot=0, y = (cumsum(h) - h/2) / sum(h) )) Cheers Felix On 2 June 2011 13:59, Richard M. Heiberger r...@temple.edu wrote: I would like the ylab in the second, resized graph to be centered on the actual positions of the panels of the second graph, not on the positions appropriate for the first graph. How can that be specified. Toggle the two graphs to see that the ylab is identically spaced in both, even though the panels are differently sized. Thanks, Rich windows.options(record=TRUE) ## We need to compare two graphs. This is the correct statement for windows. require(lattice) require(latticeExtra) A - barchart(matrix(1:10,5,2)) B - barchart(matrix(1:6,3,2)) C - barchart(matrix(1:8,4,2)) ABC - c(A, B, C, x.same=TRUE, layout=c(1,3)) ABCu - update(ABC, ylab=list(c(AAA, BBB, CCC), rot=0)) update(ABCu, main=ylab is centered on each of the panels) ABCur - resizePanels(ABCu, h=c(5,3,4)) update(ABCur, main=ylab is centered on previous panel positions.) [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] how to enclose two xyplot
Hi, Could you not simplify your a and b plots into one like xyplot(NDVI_P10 + AVG_NDVI_P10 ~ dek_num | Year, data=data, lty = 3:2, col = c(darkgrey, black), ..., [etc] auto.key = list(lines = TRUE, points = FALSE)) Otherwise please provide a commented, minimal, self-contained, reproducible example. Regards Felix On 15 April 2011 18:25, Francesco Nutini nutini.france...@gmail.com wrote: Sorry, my previous mail was incomplete. I mean, one of my xyplot is build with the command doubleYScale (in order to overlap two line with different Y-axis). But doubleYScale doesn't run with the nice command that you have suggested: first plot: a-xyplot(NDVI_P10~dek_num | Year, type=a, data=data, xlim=c(1,37), ylim=c(0.1,0.8), as.table = TRUE, layout = c(13,1), aspect = 2, col=darkgrey, col.axis=black, lwd=3, grid=T, par.settings = list(strip.background = list(col = c(gray90 second plot: b-xyplot(AVG_NDVI_P10~dek_num | Year, type=a, data=data, xlim=c(1,37), ylim=c(0.1,0.8), as.table = TRUE, layout = c(13,1), aspect = 2, col=black, col.axis=black, lwd=2) overlap first and second: double- update(doubleYScale(a, b, add.ylab2 = TRUE), par.settings = simpleTheme(col = c(black,black))) third plot: z- xyplot(z_NDVI_P10 ~dek_num | Year, type=h, data=data, xlim=c(1,37), ylim=c(-2.5,2.5), as.table = TRUE, layout = c(13,1), aspect = 2, col=black, col.axis=black, lwd=3, grid=T, par.settings = list(strip.background = list(col = c(gray90 enclose (?c.trellis): c( z,double, x.same = TRUE, y.same = T, layout = c(13,2)) Maybe there is no solution but, anyway, thanks for help! francesco From: nutini.france...@gmail.com To: baptiste.aug...@googlemail.com CC: r-help@r-project.org Subject: RE: [R] how to enclose two xyplot Date: Thu, 14 Apr 2011 15:31:12 + ok ?c.trellis works well. But I still have a problem. One of my plot is a combination of two xyplot on different scales: a-xyplot(NDVI_P10~dek_num | Year, type=a, data=data, xlim=c(1,37), ylim=c(0.1,0.8), as.table = TRUE, layout = c(13,1), aspect = 2, col=darkgrey, col.axis=black, lwd=3, grid=T, par.settings = list(strip.background = list(col = c(gray90 b-xyplot(AVG_NDVI_P10~dek_num | Year, type=a, data=data, xlim=c(1,37), ylim=c(0.1,0.8), as.table = TRUE, layout = c(13,1), aspect = 2, col=black, col.axis=black, lwd=2) update(doubleYScale(a, b, add.ylab2 = TRUE), par.settings = simpleTheme(col = c(black,black))) From: nutini.france...@gmail.com To: baptiste.aug...@googlemail.com CC: r-help@r-project.org Subject: RE: [R] FW: [r] how to enclose two xyplot Date: Thu, 14 Apr 2011 07:46:31 + Did you mean this? http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=latticeExtra:c.trellis In fact I'm already using latticeExtra package because my xyplot is little bit complicated... So, I'm tring, thanks fro tricks baptiste! Francesco Date: Thu, 14 Apr 2011 08:52:45 +1200 Subject: Re: [R] FW: [r] how to enclose two xyplot From: baptiste.aug...@googlemail.com To: nutini.france...@gmail.com CC: r-help@r-project.org Hi, Have you tried ?c.trellis in the latticeExtra package? HTH, baptiste On 13 April 2011 23:36, Francesco Nutini nutini.france...@gmail.com wrote: Dear R-users, I have to plot two xyplot, and I wish to enclose this two graphs with just one headline, the same x scale, the same grid etc. These parameters should tie in, in order to obtain, visually, a unique graph formed by two xyplot. I try to give an idea: xyplot1: |_|_|_| xyplot2: |_|_|_| what i want: | | | | |_|_|_| I tried to use the command par, but it's doesn't work with xyplot. The two plot have, by default, the same x-axis scale. I know it's just a visual solution, but it could be nice for a paper! Thanks a lot, Francesco Nutini PhD student [[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. [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] recursive do.call
It is complicated if the argument list is all mixed in together as in your example. You would have to look up argument lists for possible S3 methods (e.g. 'digits' is an argument to print.default), and then there is S4 to think about. Also, can arguments be matched by partial names? Can they be given in the argument list without a name? My point is that you had better have a good reason to want to do it this way... Cheers Felix On 14 March 2011 14:24, Jeroen Ooms jeroeno...@gmail.com wrote: I would like to define a recursive equivalent to call or do.call, which takes a vector of multiple function names and 'chains' them, by greedy matching of arguments down the chain. For example, I would like to be able to do: rec.do.call(c(glm,coef,print), list(formula=dist~speed, digits=3, data=cars)); which would then be equivalent to: print(coef(glm(formula=dist~speed, data=cars)), digits=3); I've been playing around with a recursive function with ellipses, but I can't wrap my head around it. -- View this message in context: http://r.789695.n4.nabble.com/recursive-do-call-tp3353074p3353074.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function
Yes, it is intersect rather than intersection, sorry. And in panel.text() the x and y were switched, so just reverse the first two arguments. Thats what comes from posting from an iGizmo with no R to test my code. 2011/3/11 Umesh Rosyara rosyar...@gmail.com: Thank you so much for the advice. The R could not find function intersection. Do I need additional package to have this function active. I tried intersect instead has no effect. xyplot(p ~ xvar|chr, data=dataf, panel=function(x, y, subscripts){ panel.xyplot(x, y) ok= intersection(subscripts, which(dataf$p 0.05)) with(dataf[ok,], panel.text(p, xvar, name)) }, as.table=T, subscripts=T) Best Regards Umesh R From: foolish.andr...@gmail.com [mailto:foolish.andr...@gmail.com] On Behalf Of Felix Andrews Sent: Thursday, March 10, 2011 7:01 AM To: Umesh Rosyara Cc: R mailing list; deepayan.sar...@r-project.org Subject: Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function Notice that pvals is a subset of dataf so 'subscripts' can not be applied directly to pvals. Instead you should do the subsetting inside the panel function. e.g. ok - intersection(subscripts, which(dataf$p 0.05)) with(dataf[ok,], panel.text(p, xval, name)) By the way you should include the dots (...) in your panel function arguments and pass them on to panel.xyplot. On Thursday, 10 March 2011, Umesh Rosyara rosyar...@gmail.com wrote: Lattice-experts: Thank you for those who have responded earlier. I have not got a perfect solution yet but tried several ways, unless anybody really lattice killer steps up, I will leave it and see alternatives. Sorry to send it again. #Data name - c(paste (M, 1:1000, sep = )) xvar - seq(1, 1, 10) chr - c(rep(1,200),rep(2,200), rep(3,200), rep(4,200), rep(5,200)) set.seed(134) p - rnorm(1000, 0.15,0.05) dataf - data.frame(name,xvar, chr, p) dataf$chr - as.factor(dataf$chr) #subset data pvals - dataf[dataf$p 0.05,] # unsuccessful commands xyplot(p ~ xvar|chr, data=dataf, panel=function(x, y, subscripts){ panel.xyplot(x, y) panel.xyplot(pvals$xvar[subscripts],pvals$p[subscripts], pch=6) panel.abline(h=0.01, col=red) panel.text(pvals$xvar[subscripts], pvals$p[subscripts], pvals$name[subscripts], col=green2) }, as.table=T, subscripts=T) Best Regards Umesh R _ From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Tuesday, March 08, 2011 12:00 AM To: Umesh Rosyara Cc: Jorge Ivan Velez; Dennis Murphy; sarah.gos...@gmail.com; R mailing list Subject: Re: still a problem remainingRE: [R] Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function As I believe I already told you in my original reply, you have to make use of the subscripts argument in the panel function to subscript the P values etc. vector to be plotted in each panel. Something like: (untested) panel = function(x, y,subscripts,...) { panel.xyplot(x, y,...) panel.abline(h=0.01, col=red) panel.text(xv1[subscripts], p1[subscripts], n1[subscripts], col=green2) } Also,in future, please send plain text email, as requested in the guide. Your message was in an annoying blue font in my gmail reader. Cheers, Bert On Mon, Mar 7, 2011 at 5:26 PM, Umesh Rosyara rosyar...@gmail.com wrote: Hi Lattice Users I have been working to fix this problem, still I am not able to solve fully. I could label those names that have pvalue less than 0.01 but still the label appears in all compoent plots eventhough those who do have the pvalue ! How can I implement it successuflly to grouped data like mine. You help is highly appreciated. #my data name - c(paste (M, 1:1000, sep = )) xvar - seq(1, 1, 10) chr - c(rep(1,200),rep(2,200), rep(3,200), rep(4,200), rep(5,200)) set.seed(134) p - rnorm(1000, 0.15,0.05) dataf - data.frame(name,xvar, chr, p) dataf$chr - as.factor(dataf$chr) # lattice plot: As far as I can go now ! little progress but final push required ! require(lattice) pvals - dataf[dataf$p 0.01,] p1 - pvals$p n1 - pvals$name xv1 - pvals$xvar xyplot(p ~ xvar|chr, data=dataf, panel = function(x, y) { panel.xyplot(x, y) panel.abline(h=0.01, col=red) panel.text(xv1, p1, n1, col=green2) }) Thank you in advance. Best Regards Umesh R From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Sunday, March 06, 2011 10:50 AM To: Umesh Rosyara Cc: Jorge Ivan Velez; Dennis Murphy; sarah.gos...@gmail.com; R mailing list Subject: Re: [R] Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function This is easy to do
Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function
in this situation. Unless, there i -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] overlap different line in a xyplot (lattice)
On 12 December 2010 00:08, Peter Ehlers ehl...@ucalgary.ca wrote: On 2010-12-11 03:12, Francesco Nutini wrote: mmmh, yes this method works... but I have to overlap this two graphs: xyplot(a ~b |sites, data=dataset, col=red) xyplot(c ~b |sites, data=dataset, col=blue) a, b and c are columns in the same dataset. Sites is also a column in the dataset, but it's a factorial variables. How can I use your method? The idea is the same: you need to get your data into long format with a grouping variable and then use the 'groups' argument to xyplot. Here's fake data frame (you should have provided one): DF - data.frame(y1 = rnorm(30), y2 = rnorm(30) + 2, x = rep(1:10, 3), sites = gl(3, 10, lab=LETTERS[1:3])) ## Use the reshape2 package to melt the data: ## (or use reshape() in base R) require(reshape2) DF1 - melt(DF, measure.vars = c('y1', 'y2'), variable.name = 'grp', value.name = 'y') ## and plot: require(lattice) p - xyplot( y ~ x | sites, data = DF1, groups = grp, col = c(red, blue), type = b) print(p) Peter Ehlers By the way, in this particular case there is a shortcut which does the reshaping internally: xyplot(y1 + y2 ~ x | sites, DF, type = b) sorry for my ignorance! Francesco Nutini Date: Fri, 10 Dec 2010 10:13:00 -0800 From: ehl...@ucalgary.ca To: nutini.france...@gmail.com CC: r-help@r-project.org Subject: Re: [R] [r] overlap different line in a xyplot (lattice) On 2010-12-10 07:04, Francesco Nutini wrote: dear [R] users, is there a way to plot different data (but with the same x-variables) in the same xyplot window? There are already a similar question, but the answer is not enought explanatory... Something like this? x - rep(1:10, 2) y1 - rnorm(10); y2 - rnorm(10) + 2 y - c(y1, y2) g - gl(2, 10) xyplot( y ~ x, groups = g, type = 'b') Peter Ehlers Thanks a lot, Francesco __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] [lattice xyplot] Help needed in help in customizing the panel.abline() function
Hi Girish, Try this: disc - xyplot(cnt_gt50pct_disc ~ week_num|sku_num, data=DF,type = h,lwd=2,panel = function(x, y, ...) { panel.abline(v = x[which.max(y)], lty = 2) panel.xyplot(x, y, ...) }) -Felix On 9 December 2010 17:35, Girish A.R. garam...@gmail.com wrote: Hi folks, I need some help in customizing the abline() function to be used in a lattice plot. I have attached a reproducible example below. I need help in the following snippet: disc - xyplot(cnt_gt50pct_disc ~ week_num|sku_num, data=DF,type = h,lwd=2,panel = function(...) { panel.abline(v = 8, lty = 2) panel.xyplot(...) }) Is there a way I can give panel.abline() input from a which.max() function? Essentially I need the vertical line to be drawn at the week_num corresponding to the max (cnt_gt50pct_disc). Thanks in advance, -Girish === Lines - sku_num week_num pct_inv_left cnt_gt50pct_disc 1 1 99.88 47 1 2 99.54 109 1 3 98.7 260 1 4 97.83 202 1 5 96.53 389 1 6 94.11 450 1 7 90.42 459 1 8 86.63 448 1 9 83.39 411 1 10 77 478 1 11 71.65 476 1 12 67.3 463 1 13 62.45 472 1 14 52.47 488 1 15 40.86 486 1 16 31.34 484 1 17 23.2 472 1 18 17 458 1 19 12.66 423 1 20 10.18 364 1 21 7.6 343 1 22 3.09 343 1 23 1.05 211 2 1 99.94 30 2 2 99.4 151 2 3 98.85 146 2 4 97.92 274 2 5 97.03 204 2 6 95.59 378 2 7 92.81 452 2 8 89.07 470 2 9 85.11 454 2 10 81.68 421 2 11 75.34 479 2 12 70.05 476 2 13 66.11 456 2 14 61.85 465 2 15 53.2 485 2 16 42.75 486 2 17 33.58 481 2 18 25 477 2 19 18.13 450 2 20 12.97 416 2 21 10.03 343 2 22 7.03 293 2 23 2.33 283 2 24 0.77 116 DF - read.table(con- textConnection(Lines), skip = 1); names(DF) - scan(textConnection(Lines), what = , nlines = 1) ; close(con); require(latticeExtra) DF$sku_num - as.factor(DF$sku_num) disc - xyplot(cnt_gt50pct_disc ~ week_num|sku_num, data=DF,type = h,lwd=2,panel = function(...) { panel.abline(v = 8, lty = 2) panel.xyplot(...) }) sales - xyplot(pct_inv_left ~ week_num|sku_num, data=swtop16,type = l,lwd=2,panel = function(...) { panel.abline(h = 75, lty = 2) panel.xyplot(...) }) doubleYScale(disc, sales, style1 = 0, style2 = 2, add.ylab2 = TRUE,text = c(# stores with gt 50pct disc, % Unsold)) -- View this message in context: http://r.789695.n4.nabble.com/lattice-xyplot-Help-needed-in-help-in-customizing-the-panel-abline-function-tp3079656p3079656.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] L-shaped boxes with lattice graphs?
Here is a better approach that will keep the axis ticks as well on the two axes. ## define a lattice axis function axis.L - function(side, ..., line.col) { if (side %in% c(bottom, left)) { col - trellis.par.get(axis.text)$col axis.default(side, ..., line.col = col) if (side == bottom) grid::grid.lines(y = 0) if (side == left) grid::grid.lines(x = 0) } } ## hide panel and strip borders by using col = NA sty - list() sty$axis.line$col - NA sty$strip.border$col - NA sty$strip.background$col - NA xyplot(11:14 ~ 1:4 | rep(c(A, B), 2), axis = axis.L, par.settings = sty, scales=list(alternating=FALSE, relation=sliced), layout=c(1,2)) Cheers -Felix On 16 November 2010 16:22, John Maindonald john.maindon...@anu.edu.au wrote: Hi Felix - There's just a slight problem. This removes the tick marks. I suppose I could add a layer that has the tick marks! Cheers John. John Maindonald email: john.maindon...@anu.edu.au phone : +61 2 (6125)3473fax : +61 2(6125)5549 Centre for Mathematics Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. http://www.maths.anu.edu.au/~johnm On 15/11/2010, at 5:45 PM, Felix Andrews wrote: Hi John, Here is an example with plot borders on the left and bottom only. ## hide the usual panel and strip borders by using transparent NA sty - list() sty$axis.line$col - NA sty$strip.border$col - NA sty$strip.background$col - NA xyplot(11:14 ~ 1:4 | rep(c(A, B), 2), scales=list(x=list(alternating=FALSE, relation=sliced)), par.settings = sty, panel = function(...) { grid::grid.lines(x = 0); grid::grid.lines(y = 0) panel.xyplot(...) }, layout=c(1,2)) Hope that helps -Felix On 15 November 2010 11:00, John Maindonald john.maindon...@anu.edu.au wrote: Can anyone suggest an equivalent, for lattice graphs, of the base graphics argument bty=l? NB that I am leaving off the box around the strip, with a strip function: stripfun - function(which.given,which.panel, factor.levels=as.expression(levlist), ...){ panel.text(x=0, y=0.5, lab = as.expression(levlist[which.panel[which.given]]), adj=0) } e.g. levlist - list(A, B) xyplot(11:14 ~ 1:4 | rep(1:2,2), scales=list(x=list(alternating=c(1,1), relation=sliced)), strip=stripfun, layout=c(1,2)) John Maindonald email: john.maindon...@anu.edu.au phone : +61 2 (6125)3473fax : +61 2(6125)5549 Centre for Mathematics Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. http://www.maths.anu.edu.au/~johnm __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] L-shaped boxes with lattice graphs?
Hi John, Here is an example with plot borders on the left and bottom only. ## hide the usual panel and strip borders by using transparent NA sty - list() sty$axis.line$col - NA sty$strip.border$col - NA sty$strip.background$col - NA xyplot(11:14 ~ 1:4 | rep(c(A, B), 2), scales=list(x=list(alternating=FALSE, relation=sliced)), par.settings = sty, panel = function(...) { grid::grid.lines(x = 0); grid::grid.lines(y = 0) panel.xyplot(...) }, layout=c(1,2)) Hope that helps -Felix On 15 November 2010 11:00, John Maindonald john.maindon...@anu.edu.au wrote: Can anyone suggest an equivalent, for lattice graphs, of the base graphics argument bty=l? NB that I am leaving off the box around the strip, with a strip function: stripfun - function(which.given,which.panel, factor.levels=as.expression(levlist), ...){ panel.text(x=0, y=0.5, lab = as.expression(levlist[which.panel[which.given]]), adj=0) } e.g. levlist - list(A, B) xyplot(11:14 ~ 1:4 | rep(1:2,2), scales=list(x=list(alternating=c(1,1), relation=sliced)), strip=stripfun, layout=c(1,2)) John Maindonald email: john.maindon...@anu.edu.au phone : +61 2 (6125)3473 fax : +61 2(6125)5549 Centre for Mathematics Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. http://www.maths.anu.edu.au/~johnm __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice help required
- Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck -- View this message in context: http://r.789695.n4.nabble.com/lattice-help-required-tp2338382p2402285.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice help required
Deepayan Sarkar has a function combineLimits() in the development version of the latticeExtra package (i.e. the version on r-forge.r-project.org) which will set common scales in each row or column of your layout. It can also remove the internal axes. # Felix On 26 August 2010 04:43, Kay Cichini kay.cich...@uibk.ac.at wrote: .. thanks again, richard. and you swiftly saw the next problem comming up - when using par.settings = list(layout.widths = list(axis.panel = c(1, 0))) getting rid of the double tick labeling would be natural - but i'll leave it at that for today. many thanks, kay Richard M. Heiberger wrote: The multiple y axes are protecting you in this situation. z - cbind(rnorm(100,c(1,10),1), rnorm(100,c(20,30),1)) dotplot(z[,1]+z[,2] ~ facs$Treatment|facs$Sites, outer=TRUE, scales = list( y = list( relation=free)), ylab=c(y1, y2), xlab=c(Site 1, Site 2), strip=FALSE, main=problem) dotplot(z[,1]+z[,2] ~ facs$Treatment|facs$Sites, outer=TRUE, scales = list( y = list( relation=free, limits=list(c(-5,13),c(-5,13),c(18,32),c(18,32, ylab=c(y1, y2), xlab=c(Site 1, Site 2), strip=FALSE, main=protected) For more control (such as suppressing the y-tick labels in the right-hand column, I recommend Deepayan Sarkar's book. Rich [[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. - Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck -- View this message in context: http://r.789695.n4.nabble.com/lattice-help-required-tp2338382p2338707.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] Polygon Graph in lattice/ lattice extra
OK, I've added a 'horizontal' argument to panel.xyarea(), which is consistent with the meaning in panel.xyplot(). It is available from R-forge via SVN now, or as a built package within a day or 2 probably. Questions like this are best sent to package maintainers directly, I think. Regards # Felix On 13 August 2010 22:59, Sebastian wurster.sebast...@googlemail.com wrote: Hi, I'd like to draw a polygon graph. I used the package lattice extra which includes a function for that (see: http://latticeextra.r-forge.r-project.org/#panel.xyareatheme=default). But i don't want the polygon ending with its filled border at the x-axis (like in my code). Instead it should be rotated about 90 degrees and end with its filled border at the y-axis. I'm pleased about any suggestions or ideas. Thanks, Sebastian Here's the code: library(latticeExtra) data - as.data.frame(cbind(c(1,2,3,4,1,2,3,4),c(1,1,1,1,2,2,2,2),c(2,3.8,3,3.5,2.2,4,3.2,3.5))) x - data$V1 y - data$V3 groups - data$V2 xyplot(y ~ x, data, groups = groups, type='l', par.settings = simpleTheme(col = c(grey, rgb(166,27,30,maxColorValue = 255)), lwd = c(5,2)), superpose = TRUE, panel = panel.superpose, panel.groups = function(..., group.number) { if (group.number == 1) panel.xyarea(...) else panel.xyplot(...) panel.grid(h=FALSE, v=-1, col.line=grey) }, auto.key=list(columns=2, space=bottom, cex=0.8, size=1.3, adj=1, between=0.2, between.colums=0.1, points = FALSE, rectangles = TRUE)) -- View this message in context: http://r.789695.n4.nabble.com/Polygon-Graph-in-lattice-lattice-extra-tp2324156p2324156.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] xyplot with all columns of a data.frame on a single plot
One method: dd - do.call(make.groups, mydata[,-1]) dd$X - mydata$X xyplot(data ~ X | which, dd) Another method: form - paste(paste(colnames(mydata)[-1], collapse = + ), ~ X) xyplot(as.formula(form), mydata) Yet another method: library(latticeExtra) xyplot.list(mydata[,-1], FUN = function(z, ...) xyplot(z ~ mydata$X, ...)) On 27 July 2010 12:26, Rajarshi Guha rajarshi.g...@gmail.com wrote: Hi, I have a data.frame with columns named X, D1, D2, D3 I know I can get a single plot with 3 curves by doing xyplot(D1 + D2 + D3 ~ X, data) but in some cases I might have columns D1 ... D10. Is there a way to plot all 10 columns without having to specify each individual term? (By analogy with formulae in lm, I thought, xyplot(. ~ X, data) would work, but it didn't) Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice: option to sort x when type = l
try type = a -Felix On 27 July 2010 14:11, Prasenjit Kapat kap...@gmail.com wrote: Hi, (please Cc me) In xyplot (), type = l (or one that includes l, *el*) is (generally) meaningful only when the 'x' variable is sorted. In practice, one either sorts the data frame before hand or writes a tiny panel function which sorts the supplied x and then calls the default panel.xyplot(). Trouble arises when there is a conditional variable as well as a groups argument. Of course, sorting the data frame before hand is the simplest solution. But, when one wishes to plot against multiple 'x' variables the data has to be sorted each time, which, to me, doesn't seem the right way (of course, a personal opinion). Hence a feature request to add a sort option when type = l. Before giving a reproducible example, is there anything even simpler that I have missed? Example: Everything included: source ('http://www.stat.osu.edu/~pkapat/miscl/Code4xyplot_sort_type_l.R') OR, step by step: library (lattice) # toy data D - read.csv ('http://www.stat.osu.edu/~pkapat/miscl/Data4xyplot_sort_type_l.csv') # default behavior: obviously wrong xyp1 - xyplot (y ~ x/1000 | C, groups = G, data = D, type = o, main = 'Wrong behavior, obviously') # simplest soln: xyp2 - xyplot (y ~ x/1000 | C, groups = G, data = with (D, D[do.call (order, list (x, C, G)),]), type = o, main = 'Using pre-sorted data frame') # hack: # adds an additional `if' inside the `if (l %in% type) {...}' block of the default panel.xyplot () # which reads default.args$sort.type.l (this should be set to FALSE, by default) source ('http://www.stat.osu.edu/~pkapat/miscl/panel.xyplot.sort.R') lattice.options (default.args = list (sort.type.l = TRUE)) xyp3 - update (xyp1, main = 'Using hacked panel.xyplot', panel = function (...) panel.xyplot (...)) # using the hacked panel.xyplot () # display: plot (xyp1); dev.new (); plot (xyp2); dev.new (); plot (xyp3) Regards, -- Prasenjit __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] print.trellis draw.in - plaintext (gmail mishap)
The problem is that you have not pushed your viewport so it doesn't exist in the plot. (You only pushed the layout viewport). grid.ls(viewports = TRUE) ROOT GRID.VP.82 Try this: vp - vplayout(2,2) pushViewport(vp) upViewport() grid.ls(viewports = TRUE) #ROOT # GRID.VP.82 #GRID.VP.86 print(p, newpage = FALSE, draw.in = vp$name) -Felix On 13 July 2010 01:22, Mark Connolly wmcon...@ncsu.edu wrote: require(grid) require(lattice) fred = data.frame(x=1:5,y=runif(5)) vplayout - function (x,y) viewport(layout.pos.row=x, layout.pos.col=y) grid.newpage() pushViewport(viewport(layout=grid.layout(2,2))) p = xyplot(y~x,fred) print( p,newpage=FALSE,draw.in=vplayout(2,2)$name) On Mon, Jul 12, 2010 at 8:58 AM, Felix Andrews fe...@nfrac.org wrote: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Yes, please, reproducible code. On 10 July 2010 00:49, Mark Connolly wmcon...@ncsu.edu wrote: I am attempting to plot a trellis object on a grid. vplayout = viewport(layout.pos.row=x, layout.pos.col=y) grid.newpage() pushViewport(viewport(layout=grid.layout(2,2))) g1 = ggplot() ... g2 = ggplot() ... g3 = ggplot() ... p = xyplot() ... # works as expected print(g1, vp=vplayout(1,1)) print(g2, vp=vplayout(1,2)) print(g3, vp=vplayout(2,1)) # does not work print( p, newpage=FALSE, draw.in=vplayout(2,2)$name) Error in grid.Call.graphics(L_downviewport, name$name, strict) : Viewport 'GRID.VP.112' was not found What am I doing wrong? Thanks! __ 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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ __ 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.
Re: [R] table() of a factor
Just use factor(), not levels(); you can pass a factor to factor() too. x - factor(c(rep(a,3),b,d), levels = letters[1:5]) table(x) x a b c d e 3 1 0 1 0 Cheers, -Felix On 29 June 2010 20:59, Robin Hankin rk...@cam.ac.uk wrote: Hi suppose I have a factor 'x': x - as.factor(c(rep(a,3),b,d)) table(x) x a b d 3 1 1 But this is not what I want because I need to include the fact that the count of c is zero. I can't just change the levels of x: levels(x) - c(a,b,c,d) table(x) x a b c d 3 1 1 0 because this records the single d in the original 'x' as a c. What I want is: a b c d 3 1 0 1 How to get this from 'x'? (my real application has dozens of levels with complicated names). -- Robin K. S. Hankin Uncertainty Analyst University of Cambridge 19 Silver Street Cambridge CB3 9EP 01223-764877 __ 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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Lattice plotting question
Oh, if you want to put the panels on the same scale, see resizePanels() from the latticeExtra package. That does something like print(xyplot(...), panel.height = list(x = c(50,100), units = null)) but figures out the ratios automatically. -Felix On 28 June 2010 08:46, David Warren davideugenewar...@gmail.com wrote: That achieves the desired alignment, but squishes all of the data in the top xyplot, which has a maximum y-value of around 50. Any thoughts on a means of moving the axis without changing the range? Thanks! On Fri, Jun 25, 2010 at 6:42 PM, Felix Andrews fe...@nfrac.org wrote: ylim = extendrange(c(0,100)) ? On 26 June 2010 01:42, David Warren davideugenewar...@gmail.com wrote: Hi all, I'm working on some plots using lattice (R 2.10.1), and have entered the polish phase. I've produced a satisfactory pair of xyplots ( http://imgur.com/EyXGi.png), but would like to align the y-axes of the top and bottom plots. I assume that I need to adjust axis padding or something, but I can't figure this one out. Thanks for any help! Dave -- Post-doctoral Fellow Neurology Department University of Iowa Hospitals and Clinics davideugenewar...@gmail.com [[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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Post-doctoral Fellow Neurology Department University of Iowa Hospitals and Clinics davideugenewar...@gmail.com -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Label Values in levelplot
something like panel = function(x, y, z, ...) { panel.levelplot(x, y, z, ...) panel.text(x, y, labels = z) } (if you have multiple panels you will need to use 'subscripts' too) On 25 June 2010 13:16, Ben Wilkinson bjlwilkin...@gmail.com wrote: I am trying to add labels equal to the value in a levelplot. I believe that panel may be the way to go but cannot understand the examples. In the following example: X,Y,Z A,M,100 A,M,200 B,N,150 B,N,225 I would like to label each of the rectangles 100,200,150 and 225 and colour according to the value The colouring is achieved by levelplot(z ~ x *y , data) but then I get stuck with the labels Thanks [[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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Lattice plotting question
ylim = extendrange(c(0,100)) ? On 26 June 2010 01:42, David Warren davideugenewar...@gmail.com wrote: Hi all, I'm working on some plots using lattice (R 2.10.1), and have entered the polish phase. I've produced a satisfactory pair of xyplots ( http://imgur.com/EyXGi.png), but would like to align the y-axes of the top and bottom plots. I assume that I need to adjust axis padding or something, but I can't figure this one out. Thanks for any help! Dave -- Post-doctoral Fellow Neurology Department University of Iowa Hospitals and Clinics davideugenewar...@gmail.com [[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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Lattice legend
2010/6/23 Seth W Bigelow sbige...@fs.fed.us: with(alt.data[[which.packet()[1]]] statements. It all graphs out beautifully, but none of the usual tricks to get the proper legend to plot are working, i.e., using auto.key, key, etc. You haven't told us exactly what you mean by proper legend, but it is generally a good idea to use the 'par.settings' argument with 'auto.key'. Try: sup.sym$cex - 1.5 graf - xyplot(t~CC|dep,d, groups=tx, alt.data=s, #pch = sup.sym$pch, ## omit this; instead: par.settings = list(superpose.symbol = sup.sym), #cex=1.5, ## (other stuff) panel = mypanel, auto.key = list( text = c(heavy thin,light thin, control, group), columns=2 ), aspect=xy) graf One message I keep getting is Error in key[[i]][[1]] - NULL : more elements supplied than there are to replace Any suggestions will be appreciated --Seth Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California __ 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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Unspecified [upper] xlim/ylim?
You can use one-sided limits like ylim = c(0, NA), xlim = c(NA, 1) in ggplot2 and lattice = 0.18 (approximately; the version with R 2.11.0 will do it). -Felix On 16 June 2010 01:49, Ted Harding ted.hard...@manchester.ac.uk wrote: Greetings! I would like to be able to specify a fixed (say) lower limit for plotting, while leaving the upper limit floating, when plotting. The context is that the maximum in the data to be plotted is unpredictable, being the consequence of a simulation, whereas I know that it cannot be less than (say) 0; and I want to fix the lower limit at 0 in any plot, leaving the upper limit to be assigned by plot() as a result of the computed values. I know I can do this by determining the max() of the data, and then computing a Ymax to put in (say) ylim = c(0,Ymax). However, for certain reasons, I would prefer not to have to do this. (And it's just a preference ... ). Whereas one can leave the whole issue of setting both plotting limits to plot(), by not specifying ylim (or xlim), or one can explcitily specify both the upper and lower limits by (say) ylim=c(Ymin,Ymax), there seems to be no way of fixing one and leaving the other floating so that plot() would do its own thing. ylim requires two numbers to be given. Things like ylim=c(0,) or ylim=c(0,NA) would generate an error. Am I chasing a phantom? Or is there a way? ThanksTed. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 15-Jun-10 Time: 16:49:09 -- XFMail -- __ 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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Overlay of barchart and xyplot
=black,pch=c(16,17),lty=c(1,1,1,2,1))) ## -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] duplicated() and unique() problems
On Tuesday, June 8, 2010, christiaan pauw cjp...@gmail.com wrote: Hi everybody I have found something (for me at least) strange with duplicated(). I will first provide a replicable example of a certain kind of behaviour that I find odd and then give a sample of unexpected results from my own data. I hope someone can help me understand this. Consider the following # this works as expected ex=sample(1:20, replace=TRUE) ex duplicated(ex) ex=sort(ex) ex duplicated(ex) # but why does duplicate not work after order() ? ex=sample(1:20, replace=TRUE) ex duplicated(ex) ex=order(ex) duplicated(ex) Why does duplicated() not work after order() has been applied but it works fine after sort() ? Is this an error or is there something I don't understand. The latter: order() returns the indexes into your vector, i.e. a permutation, which select the values in a sorted order. Each element is unique by definition. I have been getting very strage results from duplicated() and unique() in a dataset I am analysing. Her is a little sample of my real life problem presumably this is a data.frame... str(Masechaba$PROPDESC) Factor w/ 24545 levels 06, 71Hemilton str,..: 14527 8043 16113 16054 13875 15780 12522 7771 14824 12314 ... # Create a indicator if the PROPDESC is unique. Default false Masechaba$unique=FALSE Masechaba$unique[which(is.na(unique(Masechaba$PROPDESC))==FALSE)]=TRUE The statement above is in error. You are referring to elements of unique(Masechaba$PROPDESC) which do not correspond to the rows of Masechaba. They are different lengths. Use duplicated() instead. # Check is something happended length(which(Masechaba$unique==TRUE)) [1] 2174 length(which(Masechaba$unique==FALSE)) [1] 476 Masechaba$duplicate=FALSE Masechaba$duplicate[which(duplicated(Masechaba$PROPDESC)==TRUE)]=TRUE equivalent to Masechaba$duplicate - duplicated(Masechaba$PROPDESC) length(which(Masechaba$duplicate==TRUE)) [1] 476 length(which(Masechaba$duplicate==FALSE)) [1] 2174 # Looks OK so far # Test on a known duplicate. I expect one to be true and one to be false Masechaba[which(Masechaba$PROPDESC==2363),10:12] PROPDESC unique duplicate 24874 2363 TRUE FALSE 31280 2363 TRUE TRUE # This is strange. I expected that unique() and duplicate() would give the same results. The variable PROPDESC is clearly not unique in both cases. # The totals are the same but not the individual results table(Masechaba$unique,Masechaba$duplicate) FALSE TRUE FALSE 342 134 TRUE 1832 342 I don't understand this. Is there something I am missing? Best regards Christaan P.S sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] plyr_0.1.9 maptools_0.7-34 lattice_0.18-8 foreign_0.8-40 Hmisc_3.8-0 survival_2.35-8 rgdal_0.6-26 [8] sp_0.9-64 loaded via a namespace (and not attached): [1] cluster_1.12.3 grid_2.11.1 tools_2.11.1 [[alternative HTML version deleted]] __ r-h...@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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Overlay of barchart and xyplot
0.065934066 0.037362637 0.103296703 7919 85.7303 DCC 2004 0.887254902 0.068627451 0.044117647 0.112745098 8516 84.7028 DCC 2005 0.923728814 0.06779661 0.008474576 0.076271186 7759 79.4637 DCC 2006 0.941935484 0.04516129 0.012903226 0.058064516 6637 74.5994 DCC 2007 0.890909091 0.072727273 0.036363636 0.109090909 4288 68.593 DCH 1999 0.691176471 0.161764706 0.147058824 0.308823529 204 38.2682 DCH 2000 0.245901639 0.151639344 0.602459016 0.754098361 1099 55.3403 DCH 2001 0.525316456 0.189873418 0.284810127 0.474683544 1350 52.3413 DCH 2002 0.326599327 0.1 0.562289562 0.673400673 9332 88.5776 DCH 2003 0.797342193 0.102990033 0.099667774 0.202657807 11416 93.0988 DCH 2004 0.720430108 0.134408602 0.14516129 0.279569892 13120 94.1959 DCH 2005 0.773480663 0.066298343 0.160220994 0.226519337 13726 93.0554 DCH 2006 0.943319838 0.032388664 0.024291498 0.056680162 14393 92.2483 DCH 2007 0.961038961 0.019480519 0.019480519 0.038961039 13729 90.2417 DCK 1999 0.6 0.05556 0.3 0.38889 75 64.9573 DCK 2000 0.48 0.04 0.48 0.52 109 60.2273 DCK 2001 0.5 0.1 0.37778 0.48889 185 56.1514 DCK 2002 0.6875 0.09375 0.21875 0.3125 202 65.8192 DCK 2003 0.649122807 0.052631579 0.298245614 0.350877193 332 61.6667 DCK 2004 1 0 0 0 315 67.156 DCK 2005 0.541353383 0.157894737 0.30075188 0.458646617 603 57.967 DCK 2006 0.685314685 0.111888112 0.202797203 0.314685315 912 59.3861 DCK 2007 0.9 0.075 0.025 0.1 639 55.8722 __ 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. -- Felix Andrews / 安福立 Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] segplot (latticeExtra)
On 25 May 2010 13:07, Sebastian P. Luque splu...@gmail.com wrote: Hi, I'm having a bit of trouble with 'scales=free' in the segplot() function of latticeExtra. Say we need panels for each year, showing only those counties that are represented in each one: ---cut here---start-- library(latticeExtra) data(USCancerRates) uscr.w - subset(USCancerRates, state == Washington) uscr.w$year - gl(4, 10, length=nrow(uscr.w), labels=format(seq(2001, 2004))) segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male | year, data=uscr.w, scales=free) ---cut here---end This still plots all levels of county in every panel. Based on a similar need for dotplot in another thread, the following looked promising, but gives empty panels: ---cut here---start-- segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male | year, data=uscr.w, scales=free, prepanel=function(x, y, z, ...) { zz - z[, drop=TRUE] list(sort(unique(zz))) }, panel=function(x, y, z, ...) { zz - z[, drop=TRUE] panel.segplot(x, y, zz, ...) }) ---cut here---end Is it possible to have only counties for the particular panel (year) in these plots? Thanks. In this type of plot (it is based on levelplot() internally) you need to apply the subscripts inside the prepanel and panel functions. segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male | year, data=uscr.w, scales = list(y = list(relation = free, rot = 0)), prepanel=function(x, y, z, subscripts, ...) { ans - prepanel.segplot(x, y, z, subscripts = subscripts, ...) zz - z[subscripts, drop=TRUE] ans$ylim = levels(zz) ans }, panel=function(x, y, z, subscripts, ...) { zz - z[subscripts, drop=TRUE] panel.segplot(x[subscripts], y[subscripts], zz, subscripts = TRUE, ...) }) Cheers, -- Seb __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] x y plot with z coordinate scaling to a color value
And made slightly easier with panel.levelplot.points from latticeExtra: http://latticeextra.r-forge.r-project.org/#panel.levelplot.points On 19 May 2010 22:24, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, See also ?lattice::xyplot and ?ggplot2::geom_point , either one can do it automatically. HTH, baptiste On 19 May 2010 12:24, Jannis bt_jan...@yahoo.de wrote: Dears, before I start programming my own function I would like to ask you whether there is any function already available that lets me plot a x/y plot with the colors of the points determined by scaling a third variable z into a defined colorramp? Until now I am using a wild combination of functions to create a colorvector by hand, then calling plot(x,y,col=colors) and then using color.legend() from plotrix to add a colorbar. Is there anything where I can just call (for example) plot(x,y,z) and get a plot and a colorbar next to it? If not I have to program that myself because my current way involves a lot of steps and readjusting plotting regions. Thanks for your help! Jannis __ 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. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] help color coding map in R
Sorry, I was talking nonsense. The actual problem was in your panel function, where you extract the state boundaries, and then draw them using panel.polygon: the order of states from map() is arbitrary, and does not correspond to the color palette that you set up. I suggest using mapplot(). This matches the region names you provide to the names from the map. However (as in your original case) you do need to ensure that they match exactly, including case and sub-region names... i.e. you need to match up NatSTSummaryHigh.abi$JurisdtnStateName with map(state, regions=NatSTSummaryHigh.abi$JurisdtnStateName)$names (exactly). nclr - 4 plotclr - brewer.pal(nclr,PuRd) class - classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style=fisher ) mapplot(tolower(JurisdtnStateName) ~ STMean, data = NatSTSummaryHigh.abi, map = us.map, breaks = class$brks, colramp = colorRampPalette(plotclr)) -Felix On 18 May 2010 02:37, Anderson, Chris chris.ander...@paradigmcorp.com wrote: Flex, I apologize for not sending the data. I have attached the Rdata set and an excel version and I've attached the graph. I have not use mapplot before is that a better option if so then will you pass along the syntax I would use. As far as using the current logic, I tried adding your suggesting to the groups variable and I get the same result. I also have a field within my data called BdgtGrp, which I placed in the groups option, but the state colors don’t match the levels I have in the legend. Idealy, I would like those states that I have identified with BdgtGrp==Significanlty high be in red, purple for those identified as Mid-High and light blue for those identified as High. If not by these flags then I would want the colors be for the ranges specified within the class level. In any case, I expect Ohio, followed by New Mexico, and Arizona to be in red. In order for me to get the states highlighted in the proper color are you suggesting I do a reorder on this section of the code core.states=map(state, regions=NatSTSummaryHigh.abi$JurisdtnStateName[subscripts], plot=FALSE, fill=TRUE) ? Chris Anderson Data Analyst Medical Affairs wk: 925-677-4870 cell: 707-315-8486 Fax:925-677-4670 -Original Message- From: foolish.andr...@gmail.com [mailto:foolish.andr...@gmail.com] On Behalf Of Felix Andrews Sent: Saturday, May 15, 2010 6:41 AM To: Anderson, Chris Cc: r-help@R-project.org Subject: Re: [R] help color coding map in R The 'groups' argument should be a factor, which explicitly defines the ordering of its levels. Otherwise it is converted to a factor using the default ordering which is alphabetical. You can make a factor ordered by occurence as, eg., factor(z, levels = unique(z)). Or use reorder(). Note that data attachments don't work on this list. After constructing a minimal example, it is best to dump the required objects in a pastable form using dput(). I'm guessing you have some reason that you are not using mapplot()... -Felix On Saturday, May 15, 2010, Anderson, Chris chris.ander...@paradigmcorp.com wrote: I am trying to create a map with selected states based on highest to lowest mean cost. The following code properly selects the correct states, and the legend is properly color coded with ranges, but the colors per range does not match the state colors. I need help getting the state colors to match the ranges outlined in the legend. I have tried ordering the mean amounts and this correctly creates the vector of colors in the correct order, but when applied to the map the colors don't match. Attached is the R dataset of my data. Please help me tweak the map so the colors are properly assigned. # Get the entire US map for use later. us.map - map(state, plot = FALSE, fill = TRUE) # Calculate the range of the map (with extra margins). xl - extendrange(us.map$range[1:2]) yl - extendrange(us.map$range[3:4]) library(maps) library(lattice) library(latticeExtra) library(RColorBrewer) # creates nice color schemes library(classInt) plotclr - brewer.pal(nclr,PuRd) class - classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style=fisher ) colcode - findColours(class, plotclr) # Plot a multi-panel map of all the states, and colour xyplot(y~x | NatSTSummaryHigh.abi$PrimaryDX, data = state.center,groups=names(attr(colcode, table)), main=High Cost States by Diagnosis ( National Avg), xlim = xl, ylim = yl, scales = list(draw=FALSE), aspect = iso, xlab = NULL, ylab = NULL, strip = strip.custom(var.name=Diagnosis, sep=: , strip.names=TRUE, strip.levels=TRUE), auto.key=list(border=TRUE,space=right,text=names(attr(colcode, table))), par.settings = simpleTheme(pch=16,col=attr(colcode, palette),cex=0.9), subscripts = TRUE, panel = function(..., subscripts) { # Plot the entire US map. panel.polygon(us.map$x,us.map$y) # Select the states to plot
Re: [R] help color coding map in R
The 'groups' argument should be a factor, which explicitly defines the ordering of its levels. Otherwise it is converted to a factor using the default ordering which is alphabetical. You can make a factor ordered by occurence as, eg., factor(z, levels = unique(z)). Or use reorder(). Note that data attachments don't work on this list. After constructing a minimal example, it is best to dump the required objects in a pastable form using dput(). I'm guessing you have some reason that you are not using mapplot()... -Felix On Saturday, May 15, 2010, Anderson, Chris chris.ander...@paradigmcorp.com wrote: I am trying to create a map with selected states based on highest to lowest mean cost. The following code properly selects the correct states, and the legend is properly color coded with ranges, but the colors per range does not match the state colors. I need help getting the state colors to match the ranges outlined in the legend. I have tried ordering the mean amounts and this correctly creates the vector of colors in the correct order, but when applied to the map the colors don't match. Attached is the R dataset of my data. Please help me tweak the map so the colors are properly assigned. # Get the entire US map for use later. us.map - map(state, plot = FALSE, fill = TRUE) # Calculate the range of the map (with extra margins). xl - extendrange(us.map$range[1:2]) yl - extendrange(us.map$range[3:4]) library(maps) library(lattice) library(latticeExtra) library(RColorBrewer) # creates nice color schemes library(classInt) plotclr - brewer.pal(nclr,PuRd) class - classIntervals(NatSTSummaryHigh.abi$STMean, nclr, style=fisher ) colcode - findColours(class, plotclr) # Plot a multi-panel map of all the states, and colour xyplot(y~x | NatSTSummaryHigh.abi$PrimaryDX, data = state.center,groups=names(attr(colcode, table)), main=High Cost States by Diagnosis ( National Avg), xlim = xl, ylim = yl, scales = list(draw=FALSE), aspect = iso, xlab = NULL, ylab = NULL, strip = strip.custom(var.name=Diagnosis, sep=: , strip.names=TRUE, strip.levels=TRUE), auto.key=list(border=TRUE,space=right,text=names(attr(colcode, table))), par.settings = simpleTheme(pch=16,col=attr(colcode, palette),cex=0.9), subscripts = TRUE, panel = function(..., subscripts) { # Plot the entire US map. panel.polygon(us.map$x,us.map$y) # Select the states to plot. core.states=map(state, regions=NatSTSummaryHigh.abi$JurisdtnStateName[subscripts], plot=FALSE, fill=TRUE) # Plot the states. panel.polygon(core.states$x, core.states$y, col = trellis.par.get(superpose.line)$col) } ) Chris Anderson Data Analyst Medical Affairs wk: 925-677-4870 cell: 707-315-8486 Fax:925-677-4670 /prebrThis electronic message transmission, including any attachments, contains brinformation which may be confidential, privileged and/or otherwise exempt brfrom disclosure under applicable law. The information is intended to be for the bruse of the individual(s) or entity named above. If you are not the intended brrecipient or the employee or agent responsible for delivering the message brto the intended recipient, you are hereby notified that any disclosure, copying, brdistribution or use of the contents of this information is strictly prohibited. If bryou have received this electronic transmission in error, please notify the sender brimmediately by telephone (800-676-6777) or by a reply to sender only brmessage and destroy all electronic and hard copies of the communication, brincluding attachments. Thank you.brbrFor more information on Paradigm Management Services, LLC, please visit brhttp://www.paradigmcorp.com br -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Boxplot position on X-axis relative to it's value
Dennis, this works for me: xyplot(nmgml ~ day, data = girafe, horizontal = FALSE, panel = function(...) { panel.bwplot(...) panel.average(..., fun = median, col.line = 'gray30') } ) On 13 May 2010 06:29, Dennis Murphy djmu...@gmail.com wrote: Hi: Here are a couple of ways to superimpose the boxplots with a line, using lattice and latticeExtra. Notice that the boxplots are located at the observed x values - the idea comes straight out of the example on p. 183 of the Lattice book. library(lattice) library(latticeExtra) # Connect the medians xyplot(nmgml ~ day, data = girafe, panel = panel.bwplot, horizontal = FALSE) + layer(panel.average(..., fun = median, col.line = 'gray30')) # Least squares regression line xyplot(nmgml ~ day, data = girafe, panel = panel.bwplot, horizontal = FALSE) + layer(panel.lmline(...)) Caution: be careful if you have the ggplot2 package loaded, because the layer function in ggplot2 can mask the layer function in latticeExtra. Aside: I couldn't figure out how to get the horizontal = FALSE argument to work within a single panel function that contains both panel.bwplot and panel.average. I tried xyplot(nmgml ~ day, data = girafe, panel = function(...) { panel.bwplot(..., horizontal = FALSE) panel.average(..., fun = median, col.line = 'gray30') } ) and a couple of variants thereof but couldn't get it to work. If there's an easy solution, I'd be interested in seeing it. HTH, Dennis On Wed, May 12, 2010 at 6:30 AM, Mächler Marc Jaques ma...@student.ethz.chwrote: Dear R-Experts. I collected different datas about Nitrogen content (mg/ml) in Dung. The dung was eighter fresh (day=0) or had different ages (15,29,47) to observe nutrient changes over time. Now I like to draw a boxplot. boxplot(nmgml~day) abline((nmgml~day) The Problem is, that the boxplot considers the day values as groups and not as time series (neighter when the days are numeric or factors). The result is, that the regression line looks different as when I draw a plot plot(nmgml~day) abline(nmgml~day) How can I reach that the boxplot's position on the x-axis is relative to the time value? (and the days are not just treated as groups) Data sample (Girafe-Dung) day nmgml 1 29 2.72655 2 29 2.48820 3 15 2.85945 4 15 2.58915 5 15 2.88345 6 15 2.66675 7 47 3.29125 8 15 2.44085 9 29 2.43065 10 29 2.43425 11 29 2.42705 12 0 1.12350 13 15 5.10310 14 15 0.99880 15 0 2.22350 16 47 2.18290 17 47 2.21570 18 47 2.46450 19 29 2.53350 20 47 2.78550 21 47 3.06920 22 0 2.65660 23 0 2.16650 24 0 2.20620 25 0 1.91870 26 0 2.45160 27 0 2.35980 28 0 1.99900 29 0 2.16300 30 15 2.00460 31 15 2.56220 32 47 2.38650 33 29 2.65820 34 29 2.47670 35 47 2.23770 36 29 2.40080 37 47 2.12650 38 29 2.35950 I really apreciate your help Sincerly... MJMaechler (Zurich, Switzerland) __ 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. [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice: customising panel.segments using groups
On 9 May 2010 15:25, Ky Mathews ky.math...@sydney.edu.au wrote: Hi, I want to customise the segments on an xyplot. Below is a simple example of what I'm trying to do... #Example dataset x - c(-0.25, 0.25, 0.8) y - c(-0.5, 0, 0.75) gp - c(A, I, C) my.data - cbind.data.frame(x,y,gp) #setting up the parameters to customise the lines with. ltype - c(1,2,3) env.col - c(red, black, blue) env.lwd - c(1.25, 0.75, 1.25) # Lattice plot xyplot(y ~ x, data= my.data, groups = gp, type = l, panel= panel.superpose, panel.groups = function(x,y, subscripts=subscripts, groups=groups,...){ panel.segments(0, 0, x[groups], y[groups], lty = ltype[groups], lwd=env.lwd[groups], col = env.col[groups])}) The 'panel.groups' function is passed a special argument 'group.number', not 'groups'... (Also you do not need to subset 'x' and 'y' because they are already subsetted by 'panel.superpose'.) xyplot(y ~ x, my.data, groups = gp, type = l, panel = panel.superpose, panel.groups = function(x, y, group.number, ...) { panel.segments(0, 0, x, y, lty = ltype[group.number], lwd=env.lwd[group.number], col = env.col[group.number])}) ...however, panel.superpose does this for you automatically, so you only need to pass 'lty', 'lwd' and 'col' arguments to xyplot, and these will be split up by group.number and passed on as single values. For an even better solution, it is recommended to use par.settings (or trellis.par.set for global settings), so that 'auto.key' will work: xyplot(y ~ x, my.data, groups = gp, type = l, panel = panel.superpose, panel.groups = function(x, y, ...) panel.xyplot(c(0, x), c(0, y), ...), par.settings = simpleTheme(col = c(red, black, blue), lwd = c(1.25, 0.75, 1.25), lty = c(1,2,3)), auto.key = list(lines = TRUE, points = FALSE)) HTH -Felix #The problem: I don't seem to have this quite right, as the resulting plot seems to ignore the lty, lwd, col that I set up. I tried to do this by using trellis.par.set/get but simply got confused. If I remove lty, lwd and col specifications I simply get all segments with the same attributes. i.e. it seems to be ignoring the groups #The answer I want: Segment1 has co-ordinates (0,0, x2=-0.25, y2 = -0.5) and be solid, red and of width 1.25 Segment2 has co-ordinates (0,0, x2=0.25, y2 = 0) and be dashed, black and of width 0.75 Segment3 has co-ordinates (0,0, x2=0.8, y2 = 0.75) and be dotted, blue and of width 1.25 Any help is much appreciated. Thanks and regards, Ky Mathews [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] trellis/lattice: How to plot 4 panels with the same x-scale but different y-scales?
If you need the x axes to be aligned then I assume they must represent the same variable, in which case it should be enough to have one x axis label for each column of panels. The trellis/lattice way is to use strip labels to distinguish the panels in other ways. Regards, -Felix On 7 May 2010 18:29, Marius Hofert m_hof...@web.de wrote: Dear Felix, the split and position argument can indeed be used (see below). But one has to manually adjust the position argument for the last plot (bottom right) in order to be aligned with the second (top right). This issue does not appear in the panel function approach. As you can see from the code below, it is possible to put some text under the x-axis of a panel, but the positioning depends on the scale of the y-axis... hmm... no perfect solution. Cheers, Marius ## print idea myplot - function(x,y,z,xlab,ylab){ xyplot(y~x|z,type=l,aspect=1, xlab=xlab,ylab=ylab, strip = function(...) strip.default(...), scales=list(alternating=c(1,1),tck=c(1,0)) ) } print(myplot(1:2,1:2,variable 1,x label,y label),split=c(1,1,2,2),more=TRUE) print(myplot(1:2,2:1,variable 2,x label,y label),split=c(1,2,2,2),more=TRUE) print(myplot(1:2,c(1,-1),variable 3,x label,y label),split=c(2,1,2,2),more=TRUE) print(myplot(1:2,c(-2000,2000),variable 4,x label,y label),split=c(2,2,2,2),more=FALSE) ## panel function library(lattice) x=c(1,2,1,2,1,2,1,2) y=c(1,2,2,1,1,-1,-2000,2000) z=c(1,1,2,2,3,3,4,4) # panel number xyplot(y~x|z,type=l,aspect=1,layout=c(2,2), scales=list(y=list(rot=0),relation=free,alternating=c(1,1),tck=c(1,0)), par.settings = list(clip=list(panel=FALSE), layout.widths = list(axis.panel = 2,xlab=4,ylab=4), layout.heights = list(axis.panel = 2)), panel=function(...){ panel.xyplot(...,col=1) panel.text(x=unit(1.5,npc),y=unit(-1.7,npc),x axis) } ) On 2010-05-07, at 09:54 , Felix Andrews wrote: If it is enough to have two y labels on the left side and two x label along the bottom, you can specify xlab/ylab as vectors. Rather than drawing different xlabs or ylabs for all panels in a grid, you would typically use strips to label the panels. By the way, you could use the 'split' or 'position' arguments to print.trellis to achieve the same result as your grid layout. On 7 May 2010 01:52, Marius Hofert m_hof...@web.de wrote: Dear Deepayan, Thank you very much for your quick help. I played a bit around and came up with two methods of plotting a matrix of plots on a single page (see the code below). The first you know from my earlier postings. For this method I have the following questions: 1) Is it possible to have different x- and y-labels for each of the panels (as in the second plot)? 2) Is it possible to rotate the y-axis ticks in each panel by -90 degrees (as in the second plot)? For the second method: 3) Is it possible reduce/control the space between the panels? 4) Is it possible to align the panels according to their frame? [the panels of the variables 2 and 4 are not properly aligned as the labels for the latter need more space than the ones of the former.] Many thanks, Marius library(lattice) library(grid) ## panel function library(lattice) x=c(1,2,1,2,1,2,1,2) y=c(1,2,2,1,1,-1,-2000,2000) z=c(1,1,2,2,3,3,4,4) # panel number xyplot(y~x|z,type=l,aspect=1,layout=c(2,2), scales=list(relation=free,alternating=c(1,1),tck=c(1,0)), par.settings = list(layout.widths = list(axis.panel = 2), layout.heights = list(axis.panel = 2)), panel=function(...){ panel.xyplot(...,col=1) } ) ## grid idea myplot - function(x,y,z,xlab,ylab){ xyplot(y~x|z,type=l,aspect=1, xlab=xlab,ylab=ylab, strip = function(...) strip.default(...), scales=list(alternating=c(1,1),tck=c(1,0)) ) } grid.newpage() pushViewport(viewport(layout=grid.layout(2,2))) pushViewport(viewport(layout.pos.row=1,layout.pos.col=1)) print(myplot(1:2,1:2,variable 1,x label,y label),newpage=FALSE) popViewport(1) pushViewport(viewport(layout.pos.row=1,layout.pos.col=2)) print(myplot(1:2,2:1,variable 2,x label,y label),newpage=FALSE) popViewport(1) pushViewport(viewport(layout.pos.row=2,layout.pos.col=1)) print(myplot(1:2,c(1,-1),variable 3,x label,y label),newpage=FALSE) popViewport(1) pushViewport(viewport(layout.pos.row=2,layout.pos.col=2)) print(myplot(1:2,c(-2000,2000),variable 4,x label,y label),newpage=FALSE) popViewport(1) On 2010-05-06, at 15:09 , Deepayan Sarkar wrote: On Thu, May 6, 2010 at 6:24 PM, Marius Hofert m_hof...@web.de wrote: Thanks, Deepayan. Is it at least possible to increase the space between the panels in the following plot?: library(lattice) x=rep(c(1,2,3),4) # x values y=1:12 # y values z=rep(1:4,each=3) # panel number
Re: [R] trellis/lattice: How to plot 4 panels with the same x-scale but different y-scales?
-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] control span in panel.loess in xyplot
something like xyplot(y ~ x, data = d, groups = z, panel = panel.superpose, panel.groups = function(..., group.number) { panel.xyplot(...) span - switch(group.number, 2/3, 1/4, 1/2) panel.loess(..., span = span) }, auto.key = list(lines = TRUE)) On Friday, April 30, 2010, Santosh santosh2...@gmail.com wrote: I could not make group.number work either..how do I get that? ...panel.superpose(panel.groups=group.number(),panel.bwplot,...) ? On Thu, Apr 29, 2010 at 4:26 PM, Felix Andrews fe...@nfrac.org wrote: Within panel.superpose, the current group number is passed as group.number to the panel.groups function. On 29 April 2010 20:39, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?panel.number for lattice functions that can be used in your panel function to discover which one is currently being drawn. On Thu, Apr 29, 2010 at 6:28 AM, Santosh santosh2...@gmail.com wrote: Dear R gurus.. Is it possible to control span settings for different values of a grouping variable, when using xyplot? an example code shown below d=data.frame(x=rep(sample(1:5,rep=F),10),y=rnorm(50),z=rep(sample(LETTERS[1:2],rep=F),25)) xyplot(y~x,data=d,groups=z,panel=panel.superpose,panel.groups=panel.loess(span=c(2/3, 3/4,1/2)) or something like.. xyplot(y~x,data=d,groups=z,panel=function(...) {panel.superpose(...);panel.groups=panel.loess(span=3/4,...)}) Thanks, Santosh [[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. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] control span in panel.loess in xyplot
Within panel.superpose, the current group number is passed as group.number to the panel.groups function. On 29 April 2010 20:39, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?panel.number for lattice functions that can be used in your panel function to discover which one is currently being drawn. On Thu, Apr 29, 2010 at 6:28 AM, Santosh santosh2...@gmail.com wrote: Dear R gurus.. Is it possible to control span settings for different values of a grouping variable, when using xyplot? an example code shown below d=data.frame(x=rep(sample(1:5,rep=F),10),y=rnorm(50),z=rep(sample(LETTERS[1:2],rep=F),25)) xyplot(y~x,data=d,groups=z,panel=panel.superpose,panel.groups=panel.loess(span=c(2/3, 3/4,1/2)) or something like.. xyplot(y~x,data=d,groups=z,panel=function(...) {panel.superpose(...);panel.groups=panel.loess(span=3/4,...)}) Thanks, Santosh [[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. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Multiple cex sizes in main for xyplot?
I don't think there's a much better way to do it... but this seems to work: xyplot((0:1)~(0:1), main = textGrob(lab=c(Some Text,\nSome More Text),x=c(0.5,0.5), gp=gpar(cex=c(1.2,1.0), lineheight=2)) ) -Felix On 29 April 2010 08:06, Bert Gunter gunter.ber...@gene.com wrote: Folks: I would like to write two lines of text in two different font sizes (or faces or ...) as the title (main) of a trellis plot. The following code does it, but not well: xyplot((0:1)~(0:1), main = textGrob(lab=c(Some Text,Some More Text),y=c(.95,.8), gp=gpar(cex=c(1.2,1.0))) ) There is too much space between the title text and the plot. I assume that can be fixed by fooling with padding settings in lattice.options(), but my question is: Is there a better, simpler way to do this? Would using grid graphics directly by pushing title and plot viewports and then adding the lattice graph to the plot viewport be a better way to go? OS = Windows XP R = 2.11.0 lattice_0.18-3 device = windows Bert Gunter Genentech Nonclinical Biostatistics __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] barchart in lattice 0.18-5
On 25 April 2010 08:41, Erich Studerus erich.stude...@bli.uzh.ch wrote: Hello After updating to R version 2.11.0, the xlim argument of the lattice barchart function does no longer work as expected. For example, the following code does not produce the same result in lattice lattice_0.18-3 and lattice_0.18-5 barchart(t(matrix(1:3,1:3)),horizontal=F,box.width=1,xlim=c(0.5,3.5)) In lattice_0.18-3, I could use xlim to remove the spaces between the left y-axis and the first bar and between the right y-axis and the last bar. This is no longer possible in lattice_0.18-5. Is this a bug? Yes, and it is my fault. I am testing a fix. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] overlaying a levelplot on a map plot
You don't have to use map() to draw the map. m - map(..., plot = FALSE) xyplot(y ~ x, m, type = l, aspect = iso, par.settings = list(axis.line = list(col = transparent))) or inside a panel function, assuming appropriate scales: panel.xyplot(m$x, m$y, ...) On 23 April 2010 04:38, David Winsemius dwinsem...@comcast.net wrote: On Apr 22, 2010, at 2:24 PM, Kevin Wright wrote: Mixing base/lattice graphics can be tricky, but is possible. http://www.bioconductor.org/CRAN/web/packages/gridBase/vignettes/gridBase.pdf That could be quite useful in the future. Thanks for that. Also, did you look at Chapter 13 of the lattice book? http://lmdvr.r-forge.r-project.org/figures/figures.html I did look at the actual book, and upon doing so yet again, I would say that my comments were an accurate, if pithy, summary of the message I take away from what very little regarding base graphics appears in that chapter. -- David. Kevin On Wed, Apr 21, 2010 at 2:08 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote: I've generated a levelplot showing the density distribution of a species derived from survey transects, with lon, lat co-ordinates. I'd like to overlay this on a map of the study region specified by: map('worldHires', xlim = range(mlon), ylim = range(mlat)), where mlon, mlat specifies the study region. ?map No documentation for 'map' in specified packages and libraries: you could try '??map' ??map require(maps) Loading required package: maps map So map uses base graphics. I've tried plotting the map first, then using the options: 'add=TRUE, axes=FALSE' in the levelplot, levelplot is a lattice function. You will have failure with most efforts to mix base and grid graphics. but this doesn't work - a new plot is generated for the level plot despite the 'add' option. If I try to add the map on top of the level plot, they are not to the same scale. Any suggestions on how to get round this. Thanks -- David Winsemius, MD West Hartford, CT __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] overlaying a levelplot on a map plot
You are plotting the entire lattice plot (including axes, margins etc) in the grid viewport. What you want to do is to call the panel function, panel.levelplot(), instead. However, why not just mm - map('worldHires', plot = FALSE) levelplot(z~x+y,xyz, mm = mm, panel = function(..., mm) { panel.levelplot(...) panel.lines(mm$x, mm$y) }) On 23 April 2010 06:16, Simon Goodman s.j.good...@leeds.ac.uk wrote: Thanks for those pointers making some progress now The following will put the levelplot on to the map, but the not with the co-ordinates aligned... The level plot appears on a slightly larger scale compared to the underlying map. In both the map and levelplot, the coordinates are in lon, lat decimal degrees. Hopefully I'm nearly there, with 1 or 2 tweaks. library(gridBase) mlat-c(n1,n2) mlon-c(n3,n4) map('worldHires', xlim = range(mlon), ylim = range(mlat)) axis(1);axis(2);axis(3);axis(4) lvl.plot-levelplot(z~x+y,xyz,pretty=TRUE,at=at,col.regions=cl) vps - baseViewports() pushViewport(vps$inner, vps$figure, vps$plot) pushViewport(viewport(print(lvl.plot, newpage=FALSE))) popViewport() popViewport(3) However after the line 'pushViewport(viewport(print(lvl.plot, newpage=FALSE)))' an error is returned: Error in unit(x, default.units) : (list) object cannot be coerced to type 'double' -- View this message in context: http://r.789695.n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2021128.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Overlay of barchart and xyplot
Huapeng, It sounds like you have different y scales on the two plots you want to overlay? If so you could try doubleYScale() from the latticeExtra package. Please post a minimal, reproducible example (with data-generating code that can be pasted in to R) if you want more help. Regards -Felix On 20 April 2010 07:34, Chen, Huapeng FOR:EX huapeng.c...@gov.bc.ca wrote: Hello R Folks, I am new to R. I have been struggling to overlay a barchart with a xyplot together on one plot but did not get this worked out. Any help and idea are greatly appreciated. I attached R scripts for barchart and xyplot below and also data I used. What I am trying to do is just to put the barchart and xyplot together on one plot. Huapeng dispersal_infestation.csv ## ## barchart dispersal_infestation - read.table('Z:/project/bcmpb/pattern_process/data/BCMPB_MODEL/R_stat/dis persal_infestation.csv', header=T, sep=,) attach(dispersal_infestation) dispersal_infestation$Year - factor(dispersal_infestation$Year, levels = c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008) , ordered = TRUE) barchart(dispersal_infestation$SPG_PER*100 + dispersal_infestation$SPP_PER*100 + dispersal_infestation$SPP_PER*100 ~ dispersal_infestation$Year | dispersal_infestation$District, #data=dispersal_infestation, layout=c(4,7), stack=TRUE, ## ## ## xyplot attach(dispersal_infestation) dispersal_infestation$Year - factor(dispersal_infestation$Year, levels = c(1999,2000,2001,2002,2003,2004,2005,2006,2007,2008) , ordered = TRUE) library(lattice) my.theme - list( axis.components = list(left = list(tck = 0.5, pad1 = 1, pad2 = 2), top = list(tck = 0, pad1 = -1.3, pad2 = 0), right = list(tck = 0.5, pad1 = 1, pad2 = 2), bottom = list(tck = +0.5, pad1 = 1, pad2 = 2))) trellis.par.set(theme = my.theme) panel1 = function(x, y) { #panel.loess(x, y, lwd=2.5, col=black) panel.xyplot(x, y, pch=18, col=black, cex=1.5,type='b',lwd=2) } #xyplot(log(dispersal_infestation$COUNT) ~ dispersal_infestation$Year | dispersal_infestation$ORG_UNIT_N, xyplot(sqrt(dispersal_infestation$Infestation_NUM) ~ dispersal_infestation$Year | dispersal_infestation$District, data=dispersal_infestation, layout=c(5,5), strip = strip.custom( bg=light grey), panel=panel1, xlab=Year, ylab=Square roots of number of infested cells, main=BC MPB infestation by forest districts) ### = Huapeng Chen Landscape Modeling Biologist Research Branch Ministry of Forests and Range Phone: 250-387-2710 Fax: 250-387-0046 Email: huapeng.c...@gov.bc.ca 5th Floor -727 Fisgard Street Victoria, BC V8W 1N1 P.O.Box 9519 Stn. Prov. Govt. Victoria, BC V8W 9C2 = __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] how to draw multiple vertical bands
There is panel.xblocks() in the latticeExtra package: http://latticeextra.r-forge.r-project.org/#panel.xblocks and a corresponding base graphics function xblocks() in the development version of the zoo package (not in the current CRAN release). On 15 April 2010 00:36, senne wase...@gmail.com wrote: hi R gurus I saw some graphs with vertical band like this one: http://pragcap.com/wp-content/uploads/2010/04/GS.png how to draw the blue band in R, can't find any clue to do this,any ideas? thanks in advance [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Placing the ≥ symbol in the Trellis custom strip
See ?plotmath for how to add mathematical symbols and markup to plots. e.g. xyplot(1:10 ~ 1:10 | factor(1:2), strip = strip.custom(factor.levels = expression( 90 kg, = 90 * kg))) On 9 April 2010 06:45, mahesh samtani msamt...@gmail.com wrote: Hello, I am trying to use ≥ symbol in the Trellis custom strip. The ascii ALT Key for this symbol is 242. However, when I try \242 90 kg I get the ¢ symbol in the trellis custom strip. Can some one kindly help me? Thanking you in advance, MNS [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] 3-D response surface using wireframe()
to use it. screen: A list determining the sequence of rotations to be applied to the data before being plotted. The initial position starts with the viewing point along the positive z-axis, and the x and y axes in the usual position. Each component of the list should be named one of x, y or z (repititions are allowed), with their values indicating the amount of rotation about that axis in degrees. Can anyone explain to me how the screen argument works? And what values (x,y,z) I should choose for the orientation that I want? Another question is wireframe(0 will draw all 8 edges of the cubic by default, is there anyway that I can control what edges I can draw, what I can hide? thanks very much! John __ 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. David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice background grid
The default settings come from trellis.par.get(reference.line) On 9 April 2010 13:07, Wen Huang whuang.u...@gmail.com wrote: Hi, I wonder if anyone knows how to control color and darkness of the background grid generated by ' type = c(g, p) ' in a lattice plot (e.g., in xyplot). The documentation does not seem to offer a way to change them. Thanks a lot! Wen __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Palette color order in bwplot (lattice violin plot) vs. boxplot
On 8 April 2010 03:34, Luigi Ponti lpo...@inbox.com wrote: Thanks for the hint, Felix: the following code makes it but (don't know why) the median dots disappear. bwplot(count ~ spray, data = InsectSprays, groups = spray, panel = panel.superpose, panel.groups = function(..., box.ratio) { panel.violin(..., varwidth = FALSE, box.ratio = box.ratio, cut = 0) panel.bwplot(..., box.ratio = .1) }, fill = MyPalette ) I tried to change box.dot parameter to no avail. Not sure what is going on here. It would appear that the panel.groups = function(){} is not sure where to read graphical parameters from (just guessing). It would be interesting to know your opinion. The problem is that panel.superpose() passes on arguments 'col.line' and 'col.symbol', but unless otherwise specified, 'col' is passed as NA (which is an invisible color). Your options are to specify pch = |, which is not affected by 'col', or to pass 'col' explicitly: bwplot(count ~ spray, data = InsectSprays, groups = spray, panel = panel.superpose, panel.groups = function(..., box.ratio, col) { panel.violin(..., col = col, varwidth = FALSE, box.ratio = box.ratio, cut = 0) panel.bwplot(..., col = black, box.ratio = .1) }, fill = MyPalette, pch = 16 ) -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Error Bars in lattice- barcharts
On 8 April 2010 06:03, Ivan Gregoretti ivang...@gmail.com wrote: Hi Sam and everybody, Can you educate me a little bit on the use of barchart? A command like this barchart(~table(someProperty), data=A) produces a barchart with horizontal bars. That should be barchart(table(someProperty), data=A) (the method for objects of class table) I want to produce that graph but with VERTICAL bars. clearly, horizontal=FALSE does not work. and you will find that horizontal = FALSE does work. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Error Bars in lattice- barcharts
On 20 February 2010 11:22, Sam Albers tonightstheni...@gmail.com wrote: #I've tried to alter the panel function according to the thread to produce vertical error bars in my barcharts prepanel.ci - function(x, y, ly, uy, subscripts, ...) { y - as.numeric(y) ly - as.numeric(ly[subscripts]) uy - as.numeric(uy[subscripts]) list(ylim = range(y, uy, ly, finite = TRUE)) } panel.ci - function(x, y, lx, ux, subscripts, pch = 16, ...) { x - as.numeric(x) y - as.numeric(y) lx - as.numeric(lx[subscripts]) ux - as.numeric(ux[subscripts]) panel.arrows(x, ly, x, uy, col = 'black', length = 0.25, unit = native, angle = 90, code = 3) panel.barchart(x, y, pch = pch, ...) } # Deepayan's original example. I am unsure how to diagnose the packet error. This is where I run into problems Well, when the error message says argument 'lx' is missing, with no default, it really means that argument 'lx' is missing, with no default. Your panel function has an argument 'lx', which you forgot to change to 'ly' as you did with the prepanel function. Hope that helps... with(err.ucl, barchart(mean ~ err.date | section, group=depth, layout=c(1,3), horizontal=FALSE, scales=list(x=list(rot=45)), ly=lower.se, uy=upper.se, prepanel=prepanel.ci, panel=panel.superpose, panel.groups=panel.ci )) -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Palette color order in bwplot (lattice violin plot) vs. boxplot
On 6 April 2010 20:14, Luigi Ponti lpo...@inbox.com wrote: On 04/04/2010 06:21, Deepayan Sarkar wrote: On Thu, Apr 1, 2010 at 4:10 AM, Luigi Ponti lpo...@inbox.com wrote: Hello, I am trying to give different colors to boxes in a violin plot obtained via bwplot from lattice package using a color palette from RColorBrewer: [...] However, when I do the same thing with a violin plot from the lattice package require(lattice) bwplot(count ~ spray, data = InsectSprays, + panel = function(..., box.ratio) { + panel.violin(..., col = transparent, + varwidth = FALSE, box.ratio = box.ratio) + panel.bwplot(..., fill = MyPalette, box.ratio = .1) + } ) boxplots are colored with the right colors (each box has a different color) but with a different color order -- too bad because I would like to color code the plot according to certain pre-defined colors. Same thing (wrong color order) with a simple bwplot: bwplot(count ~ spray, data = InsectSprays, fill = MyPalette) Is there a way to get the right color (i.e. same order as in MyPalette) in bwplot/panel.violin? The correct approach would be along the lines of bwplot(count ~ spray, data = InsectSprays, groups = spray, panel = panel.superpose, panel.groups = panel.violin, col = MyPalette) (unlike panel.xyplot etc., panel.bwplot does not explicitly handle grouping). Thanks! This way I get violin plots colored in the correct order. However, I lose control on panel.violin -- not sure if/how I can regain that (i.e., the stuff the was done by the panel = function(){} above). Your previous 'panel' function could now be passed as 'panel.groups' (see ?panel.superpose); alternatively, if you have a simple panel function you can pass arguments to it directly through the main call to bwplot(). Also, I have noticed that violin plots extend beyond the data range: is this the default behavior? In ?panel.violin and ?density, I read that default parameters should allow the estimated density to drop to approximately zero at the extremes. For example, the minimum value of the count variable (data = InsectSprays) is zero, but the violin plots do extend below zero. Am I missing something? help(density) says: by default, the values of 'from' and 'to' are 'cut' bandwidths beyond the extremes of the data. and the default value of 'cut' is 3. Therefore if you want to limit the density to the data range, pass cut = 0. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] xyplot second y-xis and legend
On 29 March 2010 23:20, robbert blonk robbert.bl...@gmail.com wrote: Dear list, I try to set a secondary y-axis in a lattice xyplot. This works. However, I am unable to set a proper legend/key together with the 2nd y-axis under general xyplot procedures. See example below. The combination of the par.settings with simpleTheme and other settings seems to go wrong. I couldn't find a solution from previous topics. Any suggestions? thanks in advance! Robbert #data example inp3-data.frame(group=rep(LETTERS[1:4],4), GF=as.vector(sapply(1:4,function(x)rep(x,4))), val=c(rep(c(2,3,7,8),2),rep(c(2,3,7,8),2)*1.1)) require(lattice) #this works fine, without second y-axis: xyplot(val~GF,groups=group, data=inp3,type=o, ylab=Relatedness, xlab=genotyped fraction, par.settings=simpleTheme(pch=c(1,2,3,4),lty=c(1,2),lwd=2,cex=1.5), auto.key=list(draw=TRUE,points=TRUE,lines=TRUE, text=LETTERS[1:4])) #to set a second y-axis with an other scale: # convert data to proper scale: inp3[which(inp3$group==A|inp3$group==B),val]-inp3[which(inp3$group==A|inp3$group==B),val]*3 # set second y-axis myyscale.component - function(...) { ans - yscale.components.default(...) ans$right - ans$left foo - ans$right$labels$at ans$right$labels$labels - as.character((0.3)*foo) ans } #plot with second y-axis. This does not work: xyplot(val~GF,groups= group, data=inp3,type=o, ylab=CD, xlab=GF, scales=list(y=list(relation=free, rot=0)), yscale.component=myyscale.component, par.settings=list(grid.pars=list(fontfamily=serif,cex=1), layout.widths=list(right.padding=8), simpleTheme(pch=c(1,2,3,4),lty=c(1,2),lwd=2,cex=1.5)), auto.key=list(draw=TRUE,points=TRUE,lines=TRUE, text=LETTERS[1:4]), legend = list(right=list(fun = grid::textGrob(AB, x=4,rot = 90 'legend' overrides 'auto.key' in xyplot, as mentioned in ?xyplot You can do it in two steps: foo - xyplot(val~GF,groups= group, data=inp3,type=o, ylab=CD, xlab=GF, scales=list(y=list(relation=free, rot=0)), yscale.component=myyscale.component, par.settings=list(grid.pars=list(fontfamily=serif,cex=1), layout.widths=list(right.padding=8), simpleTheme(pch=c(1,2,3,4),lty=c(1,2),lwd=2,cex=1.5)), auto.key=list(draw=TRUE,points=TRUE,lines=TRUE, text=LETTERS[1:4])) update(foo, legend = list(right=list(fun = grid::textGrob(AB, x=4,rot = 90 -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice grob
What's wrong with using grid.grabExpr? p1 - xyplot(1:10 ~ 1:10) g1 - grid.grabExpr(print(p1)) I can imagine there would be potential problems to do with the plot-time aspect and layout calculations... On 19 March 2010 21:51, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I'm trying to arrange various grid objects on a page using a frameGrob. It works fine with basic grobs (textGrob, gTree, etc.), and also with ggplot2 objects using the ggplotGrob() function. I am however stuck with lattice. As far as I understand, lattice produces a list of class trellis, which is eventually displayed using the plot.trellis method. I am not sure if/how one can convert this list into a high-level grob. I tried the following, latticeGrob - function(p, ...){ grob(p=p, ..., cl=lattice) } drawDetails.lattice - function(x, recording=FALSE){ lattice:::plot.trellis(x$p) } p1 - xyplot(1:10 ~ 1:10) g1 - latticeGrob(p1) grid.draw(g1) # works fine but, fg - frameGrob(layout = grid.layout(1,1)) fg - placeGrob(fg, g1, row = 1, col = 1) grid.draw(fg) Error in UseMethod(depth) : no applicable method for 'depth' applied to an object of class NULL Ideas are most welcome, Best regards, baptiste sessionInfo() R version 2.10.1 RC (2009-12-06 r50690) i386-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid tools stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.8.7 digest_0.4.1 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 gridExtra_0.5 lattice_0.17-26 gtools_2.6.1 __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Obtaining the true aspect ratio for a lattice plot
Basically you want to achieve an aspect ratio of 0.5 (say) when specifying aspect = fill. You can calculate the aspect ratio after a lattice plot has been displayed: currAspect - function() { trellis.focus(panel, 1, 1, highlight = FALSE) sz - current.panel.limits(mm) trellis.unfocus() diff(sz$y) / diff(sz$x) } foo - xyplot(rnorm(100) ~ rnorm(100), aspect=fill, ## NB fill xlab=this is some extra text\n to show that the\n overall aspect ratio\n of a plot is not always\n easily determined by\n the aspect ratio specified for the data) dev.new(width = 10, height = 5) print(foo) currAspect() #[1] 0.19003 One problem is that fonts in pdf() seem to be very different to screen devices. You could probably work out which components of the plot have a fixed size, and therefore work out the requried aspect ratio... but I kinda like brute force: aspectObjective - function(height, width, target, ...) { tmp - tempfile() pdf(tmp, width = width, height = height, ...) print(trellis.last.object()) asp - currAspect() dev.off() file.remove(tmp) abs(asp - target) } print(foo) height - optimize(aspectObjective, c(1, 20), width = 10, target = 0.5, tol = 0.01)$min height #[1] 7.6928 pdf(test.pdf, width = 10, height = height) print(foo) currAspect() #[1] 0.50013 dev.off() On 10 March 2010 07:16, Ryan Hafen rha...@stat.purdue.edu wrote: I almost always supply my own aspect ratio when plotting using lattice. When I plot these to pdf, I would like to specify pdf dimensions that will result in minimal margins around the plot. In my application, resorting to a pdf cropper after plotting is not an option - I must do it in R. The problem is that I cannot determine the correct aspect ratio for the overall plot (accounting for strip labels, keys, titles, labels, etc.) that would help me determine the correct pdf dimensions. I can roughly estimate what the overall aspect ratio will be using the layout, etc., but this is not good enough. Is there a way to calculate the true overall aspect ratio for the entire plot? Example: If I make a simple plot and specify aspect=0.5, you would think that dimensions width=10, height=5 would be a good approximation, but for example: library(lattice) pdf(plot.pdf, width=10, height=5) xyplot(rnorm(100) ~ rnorm(100), aspect=0.5, xlab=this is some extra text\n to show that the\n overall aspect ratio\n of a plot is not always\n easily determined by\n the aspect ratio specified for the data) dev.off() doesn't work. It looks like the true aspect ratio of the resulting non-margin area in the pdf is about 0.86. I'd like to know this in R before making the pdf so I can specify dimensions accordingly. Any ideas? __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] calling map() in xyplot()
It seems to draw some islands... looks OK to me... what exactly is the problem? Note, you probably want to specify aspect=iso On 10 March 2010 14:42, Gurmeet r.emailing.l...@gmail.com wrote: Hi All, I'm trying to add a map on the following lattice plot, but not correctly... can anyone help please... R Code: require(lattice) us.map - map(plot = FALSE, fill = TRUE) Depth - equal.count(quakes$depth, number=8, overlap=.1) xyplot(lat ~ long | Depth, data = quakes, panel = function(...) { panel.polygon(us.map$x,us.map$y) panel.xyplot(...) } ) Any help would be greatly appreciated, Gurmeet [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] conditioning variable in panel.xyplot?
Alternatively library(latticeExtra) xyplot(y ~ x | site, d) + xyplot(y ~ x | site, q, col = red) (which is a shortcut for:) xyplot(y ~ x | site, d) + as.layer(xyplot(y ~ x | site, q, col = red)) On 9 March 2010 11:17, Seth W Bigelow sbige...@fs.fed.us wrote: Ah, wonderful, thank you for the code Deepayan. To recap for posterity: I have two datafiles, d and q: each has x-y coordinates that are conditioned by site (The actual data, for me, is maps of parent trees and their seedlings). I wanted to superimpose the xy plots of d and q, by site, without going to the trouble of merging the d q datasets into a single dataset. The solution is to use the which.packet statement is d - data.frame(site = c(rep(A,12), rep(B,12)), x=rnorm(24),y=rnorm(24)) # Create the main xy dataset q - data.frame(site = c(rep(A,7), rep(B,7)), x=rnorm(14),y=rnorm(14)) # Create the alternate xy dataset q.split - split(q, q$site) # Split up the alternate dataset by site mypanel - function(..., alt.data) { with(alt.data[[ which.packet()[1] ]], # which.packet passes index of the relevant data subset... panel.xyplot(x = x, y = y, col=red)) # ... to panel.xyplot() panel.xyplot(...) } xyplot(y ~ x | site, d, alt.data = q.split, # After providing the alternative dataset and the panel... panel = mypanel) # ...everything prints out properly, like magic! Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] ellipsis-related error: used in an incorrect context, no ... to look in
The problem is related to the processing of the 'groups' argument, which is subject to non-standard evaluation. The groups argument is substitute()d and evaluated in a special context ('data' etc). But this gets messed up if you are not passing the symbol directly. The work-around is to rewrite the call inside f.barchart (as is done in, for example, lattice:::barchart.formula) Example: f.barchart - function(...) { ccall - match.call() ccall[[1]] - quote(barchart) ccall$panel - function(x, y, ...) { panel.barchart(x, y, ...) } eval.parent(ccall) } x - data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1)) f.barchart(a ~ b, data = x, groups = c) It is also good practice to update the $call component of the trellis object to reflect your high-level function: ans - eval.parent(ccall) ans$call - match.call() ans On 19 February 2010 19:58, lith minil...@gmail.com wrote: Does nobody have an advice concerning that problem? If it is a FAQ, I'd appreciate a pointer to a discussion of this issue. With the docs accessible to me, I wasn't able to solve that problem. require(lattice) f.barchart - function(...) { barchart(..., panel = function(x, y, ...) { panel.barchart(x, y, ...) } ) } x - data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1)) f.barchart(a ~ b, data = x, groups = c) Which results in the following error being thrown: ..3 used in an incorrect context, no ... to look in Regards, Tom __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Interactively editing point labels in a graph
The built-in R graphics system was not designed for interactivity -- there is no [feasible] way to detect the data point coordinates in a base graphics plot. The playwith package tries to figure out the coordinates from the data objects given in the call: this works for simple scatterplots etc, but is non-trivial for your CA plot. You *could* define functions to enable playwith to work correctly in this case: the functions would be called something like plotCoords.plot.ca and possibly case.names.ca (if case.names.default does not already work). Regards -Felix On 6 February 2010 23:11, trece por ciento el13porcie...@yahoo.com wrote: Many thanks, Felix It worked, simply importing the emf into PowerPoint! By the way, as you are the maintainer of playwith, a question: Why is playwith unable to cope with it? I liked very much the playwith option because it is easy to use, and has all the basic capabilities that I need. Best regards, Hug --- On Wed, 2/3/10, Felix Andrews fe...@nfrac.org wrote: From: Felix Andrews fe...@nfrac.org Subject: Re: [R] Interactively editing point labels in a graph To: trece por ciento el13porcie...@yahoo.com Cc: Liviu Andronic landronim...@gmail.com, r-help@r-project.org Date: Wednesday, February 3, 2010, 4:51 PM For your situation, perhaps the best option is to save the plot in a vector format like WMF, PDF or SVG, and open it with an external editor. Inkscape is a good one. On 4 February 2010 06:46, trece por ciento el13porcie...@yahoo.com wrote: Thanks, Liviu In a first look it seems OK. Two questions: 1. Playwith accept directly the plots created by the ca package, but it seems unable to identify the point labels For example: data(smoke) smoke ca(smoke) plot(ca(smoke)) playwith(plot(ca(smoke))) Then, if I try to identify a label playwith gives the message Sorry, can not guess the data point coordinates. Please contact the maintainer with suggestions. If I ask to select the label from a table playwith sends the following message to RGui: Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 2, 0 2. Can playwith draw ellipses or any other figure around selected points? (For the first question it seems my fault, but I don't know how to fix it) Hug --- On Wed, 2/3/10, Liviu Andronic landronim...@gmail.com wrote: From: Liviu Andronic landronim...@gmail.com Subject: Re: [R] Interactively editing point labels in a graph To: trece por ciento el13porcie...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, February 3, 2010, 3:49 AM Hello On 2/3/10, trece por ciento el13porcie...@yahoo.com wrote: Dear experts, I would like to be able to interactively (if possible, with mouse and clik) edit point labels in graphs, Try playwith. Liviu particularly in multivariate graphs, such as the biplots you get after a correspondence analysis (with, for example, package ca), where labels tend to overlap. The graph aspect ratio is relevant (it needs to be mantained). And I'm working with Windows XP. In this kind of graphs points in the graph are identified with labels, generally long (see, for example: http://www.white-history.com/Greece_files/hlafreq.jpg), and sometimes -as in the example- it is good to group certain points within ellipses. Do you know if exists some package able to do this task? Thanks in advance, Hug __ 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. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider
Re: [R] Interactively editing point labels in a graph
For your situation, perhaps the best option is to save the plot in a vector format like WMF, PDF or SVG, and open it with an external editor. Inkscape is a good one. On 4 February 2010 06:46, trece por ciento el13porcie...@yahoo.com wrote: Thanks, Liviu In a first look it seems OK. Two questions: 1. Playwith accept directly the plots created by the ca package, but it seems unable to identify the point labels For example: data(smoke) smoke ca(smoke) plot(ca(smoke)) playwith(plot(ca(smoke))) Then, if I try to identify a label playwith gives the message Sorry, can not guess the data point coordinates. Please contact the maintainer with suggestions. If I ask to select the label from a table playwith sends the following message to RGui: Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 2, 0 2. Can playwith draw ellipses or any other figure around selected points? (For the first question it seems my fault, but I don't know how to fix it) Hug --- On Wed, 2/3/10, Liviu Andronic landronim...@gmail.com wrote: From: Liviu Andronic landronim...@gmail.com Subject: Re: [R] Interactively editing point labels in a graph To: trece por ciento el13porcie...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, February 3, 2010, 3:49 AM Hello On 2/3/10, trece por ciento el13porcie...@yahoo.com wrote: Dear experts, I would like to be able to interactively (if possible, with mouse and clik) edit point labels in graphs, Try playwith. Liviu particularly in multivariate graphs, such as the biplots you get after a correspondence analysis (with, for example, package ca), where labels tend to overlap. The graph aspect ratio is relevant (it needs to be mantained). And I'm working with Windows XP. In this kind of graphs points in the graph are identified with labels, generally long (see, for example: http://www.white-history.com/Greece_files/hlafreq.jpg), and sometimes -as in the example- it is good to group certain points within ellipses. Do you know if exists some package able to do this task? Thanks in advance, Hug __ 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. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Using tcltk or other graphical widgets to view zoo time series objects
You could either call a function, passing the value, or assign it to a variable in the workspace like .GlobalEnv$foo - playState$env$i Note that this `i' is one number, not a sequence, so you can't take the mean. -Felix On 1 February 2010 20:57, Research risk2...@ath.forthnet.gr wrote: Dear Felix, Thanks. That was most useful. I am having trouble though exporting values of variables to the R environment from within the playwith. Say I need to do a claculation by setting up an extra button within playwith(xyplot(dat[,c(1,i)]), parameters = list(i = 1:100, do_something = function(playState) print(playState$env$i), do_something_else = function(playstate) ###Export here mean value of sequence playState$env$i### ) ) Can I pass the value of this to the rest of R ? I could not find something in the help pages. Can you direct me to it please? Thanks + Best regards, Costas Felix Andrews wrote: The playwith package might help, though if I understand the problem correctly, the help(xyplot.zoo) example is not so relevant. If you want to switch between many series you could use a spin-button or somesuch. To execute a function you can create a button. If you have a hundred-column dataset like dat - zoo(matrix(rnorm(100*100),ncol=100), Sys.Date()+1:100) colnames(dat) - paste(Series, 1:100) Then this will give you a spin button to choose the column to plot, and a button to print out the current series number. playwith(xyplot(dat[,c(1,i)]), parameters = list(i = 1:100, do_something = function(playState) print(playState$env$i)) ) Note that the playwith package uses RGtk2, and therefore requires the GTK+ libraries to be installed on your system. On 28 January 2010 23:16, Gabor Grothendieck ggrothendi...@gmail.com wrote: There is an example of using zoo together with the playwith package at the end of the examples section of help(xyplot.zoo) which may address this. On Thu, Jan 28, 2010 at 7:10 AM, Research risk2...@ath.forthnet.gr wrote: Dear all, I am looking at the R-help entry below: http://finzi.psych.upenn.edu/R/Rhelp02/archive/26640.html I have a more complicatedt problem. I have a zoo time series frame with 100+ sequences. I want to cycle through them back and forth and compare them to the 1st column at any time. I need also a button to click when I need the viewed-selected sequence (that is being compared to the 1st column one) to be manipulated (by some algorithm or be saved individually etc. etc.)... I am trying to modify the code at the above link but somehow I can not make it to work with zoo time series objects. Any help would be greatly appreciated. Thanks in advance, Costas __ Information from ESET Smart Security, version of virus signature database 4813 (20100128) __ The message was checked by ESET Smart Security. http://www.eset.com __ 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. __ 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. __ Information from ESET Smart Security, version of virus signature database 4823 (20100201) __ The message was checked by ESET Smart Security. http://www.eset.com -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Using tcltk or other graphical widgets to view zoo time series objects
The playwith package might help, though if I understand the problem correctly, the help(xyplot.zoo) example is not so relevant. If you want to switch between many series you could use a spin-button or somesuch. To execute a function you can create a button. If you have a hundred-column dataset like dat - zoo(matrix(rnorm(100*100),ncol=100), Sys.Date()+1:100) colnames(dat) - paste(Series, 1:100) Then this will give you a spin button to choose the column to plot, and a button to print out the current series number. playwith(xyplot(dat[,c(1,i)]), parameters = list(i = 1:100, do_something = function(playState) print(playState$env$i)) ) Note that the playwith package uses RGtk2, and therefore requires the GTK+ libraries to be installed on your system. On 28 January 2010 23:16, Gabor Grothendieck ggrothendi...@gmail.com wrote: There is an example of using zoo together with the playwith package at the end of the examples section of help(xyplot.zoo) which may address this. On Thu, Jan 28, 2010 at 7:10 AM, Research risk2...@ath.forthnet.gr wrote: Dear all, I am looking at the R-help entry below: http://finzi.psych.upenn.edu/R/Rhelp02/archive/26640.html I have a more complicatedt problem. I have a zoo time series frame with 100+ sequences. I want to cycle through them back and forth and compare them to the 1st column at any time. I need also a button to click when I need the viewed-selected sequence (that is being compared to the 1st column one) to be manipulated (by some algorithm or be saved individually etc. etc.)... I am trying to modify the code at the above link but somehow I can not make it to work with zoo time series objects. Any help would be greatly appreciated. Thanks in advance, Costas __ Information from ESET Smart Security, version of virus signature database 4813 (20100128) __ The message was checked by ESET Smart Security. http://www.eset.com __ 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. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] xyplot - help with multiple Y's vs. X of a member data in multiple panels
/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. [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] xyplot: problems with column names legend
You have not said what the problem is, i.e. what you have tried and what you expect. Please post a small, reproducible example if you want help. Regards -Felix 2010/1/6 Jay josip.2...@gmail.com: Anybody? Frustrating to be unable to solve this silly little problem... On Jan 3, 12:48 pm, Jay josip.2...@gmail.com wrote: Thanks, the backtickes got the code working. However, now I cant get it to draw the legend/key. For example, look at this figure:http://osiris.sunderland.ac.uk/~cs0her/Statistics/xyplot5.png My graph is similar, but instead of 1,2,...,8 as the names of the series I want it to say Data one (a string with spaces) and so on. On Jan 3, 10:58 am, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Using backticks might work to some extent, library(lattice) `my variable` = 1:10 y=rnorm(10) xyplot(`my variable` ~ y) but if your data is in a data.frame the names should have been converted, make.names('my variable') [1] my.variable HTH, baptiste 2010/1/3 Jay josip.2...@gmail.com: Hello! one more question about xyplot. If I have data which have space in the column names, say xyz 123. How do I create a working graph where this text is displayed in the legend key? Now when I try something like xyplot(xyz 123 ~ variable1, data = mydata, ...) I get nothing. Also, is it possible to genrate the graph with xyplot(mydata[,1] ~ variable1, data = mydata, ...) and then later in the code specify the names that should be displayed in the legend? Thank you! __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] StructTS standard errors
Hi David, You might not be aware that Giovanni Petris is the author of the dlm package, a world-class package for modelling stochastic / time-varying systems. Not that I know much about this stuff. Cheers -Felix 2009/12/23 David Winsemius dwinsem...@comcast.net: On Dec 22, 2009, at 11:55 AM, Giovanni Petris wrote: David, Thank you for the insight. Right. HA1) StructTS() ships with R in package stats. HA2) I don't see anything strange or unusual in looking for standard errors of estimated parameters. In structural time series the only unknown parameters, estimated by StructTS(), happen to be variances. (Incidentally, I know how to take square roots in R) Yes. I figured most of this out after doing a bit of searching. Both of my off-target points amply illustrate my lack of experience with this particular time-series function. So let me ask a question: Would the domain of stochastic processes be relevant here? I am wondering if the theoretical results in Ito calculus might let you assign a more reasonable estimate for future behavior. My memory is that random processes with measured (past) variances under conditions of temporal homogeneity (there's probably a more mathematically correct terminology) should have a predictable relationship to the underlying variance parameter. -- David Winsemius Best, Giovanni - Original Message - From: David Winsemius dwinsem...@comcast.net Date: Monday, December 21, 2009 3:50 pm Subject: Re: [R] StructTS standard errors Alternate hypotheses: HA1: There is no one in the readership who is familiar with the function (unlikely), or among those lacking knowledge of what package it might reside in (such as myself) chose not to look up what you might have provided on the first posting: a self-contained example to work with. HA2: Your question also suggests a certain statistical confusion. Do your really want standard errors of estimated variances? That would be somewhat unusual. Or do you want to take the square-roots of the variances to get standard errors of the estimated coefficients? On Dec 21, 2009, at 4:26 PM, Giovanni Petris wrote: Sorry for asking again, but I did not receive any answers - I know it's a busy time... ;-) Shell I conclude that it is not possible to obtain standard errors from StructTS() or its output? Thanks, Giovanni Petris - Original Message - From: Giovanni Petris gpet...@uark.edu Date: Thursday, December 17, 2009 10:13 am Subject: [R] StructTS standard errors Hello, Does anybody know if (and how) it is possible to obtain standard errors of estimated variances from StructTS? (R 2.10.0). Thank you in advance, Giovanni -- David Winsemius, MD Heritage Laboratories West Hartford, CT David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] as.Date question
I don't know the details of why this is happening, but in any case it is a good idea to round() your times if you want to convert them to dates. Just as you would round() a numeric value to convert it to an integer. as.Date(round(zzz1, days)) 2009/12/21 Jason Morgan jwm-r-h...@skepsi.net: Hello, On 2009.12.20 18:06:17, MAL wrote: All! This piece of code: zzz1 - as.POSIXct(1999-03-18, tz=CET) zzz2 - as.POSIXlt(1999-03-18, tz=CET) zzz1 == zzz2 as.Date(zzz1) as.Date(zzz2) yields TRUE for zzz1==zzz2, but the two dates returned by as.Date are different: as.Date(zzz1) [1] 1999-03-17 as.Date(zzz2) [1] 1999-03-18 I'm using R 2.10.0. Would be glad for any clarifications. Thanks! I don't know why as.Date() is giving different results, but if look at the value of the variables, they are equal: zzz1 - as.POSIXct(1999-03-18, tz=CET) zzz2 - as.POSIXlt(1999-03-18, tz=CET) zzz1 == zzz2 [1] TRUE as.Date(zzz1) [1] 1999-03-17 as.Date(zzz2) [1] 1999-03-18 zzz1 [1] 1999-03-18 CET zzz2 [1] 1999-03-18 CET Maybe someone here can explain the behavior of as.Date(). Cheers, ~Jason -- Jason W. Morgan Graduate Student Department of Political Science *The Ohio State University* 154 North Oval Mall Columbus, Ohio 43210 __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] ggplot2 / lattice
something like bwplot(val ~ g | G2, dta, pch = |, box.width = 1, par.settings = list(box.rectangle = list(col = darkred, fill = grey90), box.umbrella = list(col = darkred), strip.background = list(col = transparent))) For more on the Lattice style / theme system, see show.settings() str(trellis.par.get()) 2009/12/19 Gary Miller mail2garymil...@gmail.com: Thanks Felix, I got others except: 1. Is it possible to reduce the gaps between the boxplots, may be say NO GAP. 2. I tried col=red option, but its not changing the border color of boxes. R Code: g - rep.int(c(A, B, C, D), 125) t - rnorm(5000) a - sample(t, 500, replace=TRUE) b - sample(t, 500, replace=TRUE) dta - data.frame(val = sample(t,1000), g = gl(4, 250, labels=c(A, B, C, D)) , G2 = gl(2,1, labels=c(XX, YY))) library(lattice) bwplot(val ~ g | G2, dta, panel = function(x,y,...) { panel.bwplot(x,y,..., pch=|, col=red, fill=red, box.width=.3) } ) Thanks, Gary On Thu, Dec 17, 2009 at 11:01 PM, Felix Andrews fe...@nfrac.org wrote: Look at ?panel.bwplot specifically 'fill', 'pch', and 'box.width'. 2009/12/18 Gary Miller mail2garymil...@gmail.com: @ Gabor: Thanks, it worked. @ All: Which options I should explore to change the appearance of boxes. Like, 1. Color change. 2. Fill-in boxes with colors. 3. Change dot to line (used to represent median) 4. No gaps between boxplots in each category. # R Code: g - rep.int(c(A, B, C, D), 125) t - rnorm(5000) a - sample(t, 500, replace=TRUE) b - sample(t, 500, replace=TRUE) dta - data.frame(val = sample(t,1000), g = gl(4, 250, labels=c(A, B, C, D)) , G2 = gl(2,1, labels=c(XX, YY))) library(lattice) bwplot(val ~ g | G2, dta) Thanks, Gary On Thu, Dec 17, 2009 at 10:09 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: bwplot(val ~ g | G2, dta) On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller mail2garymil...@gmail.com wrote: Hi R Users, Is there a equivalent function for the following R code in Lattice package. I want to plot a grouped box plots (grouped by two factors). g - rep.int(c(A, B, C, D), 125) t - rnorm(5000) a - sample(t, 500, replace=TRUE) b - sample(t, 500, replace=TRUE) dta - data.frame(val = sample(t,1000), g = gl(4, 250, labels=c(A, B, C, D)) , G2 = gl(2,1, labels=c(XX, YY))) # ggplot2 package required p - ggplot(dta, aes(factor(G2), val)) p + geom_boxplot(aes(fill = factor(g))) Any suggestion would be highly appreciated! Gary [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] ggplot2 / lattice
Look at ?panel.bwplot specifically 'fill', 'pch', and 'box.width'. 2009/12/18 Gary Miller mail2garymil...@gmail.com: @ Gabor: Thanks, it worked. @ All: Which options I should explore to change the appearance of boxes. Like, 1. Color change. 2. Fill-in boxes with colors. 3. Change dot to line (used to represent median) 4. No gaps between boxplots in each category. # R Code: g - rep.int(c(A, B, C, D), 125) t - rnorm(5000) a - sample(t, 500, replace=TRUE) b - sample(t, 500, replace=TRUE) dta - data.frame(val = sample(t,1000), g = gl(4, 250, labels=c(A, B, C, D)) , G2 = gl(2,1, labels=c(XX, YY))) library(lattice) bwplot(val ~ g | G2, dta) Thanks, Gary On Thu, Dec 17, 2009 at 10:09 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: bwplot(val ~ g | G2, dta) On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller mail2garymil...@gmail.com wrote: Hi R Users, Is there a equivalent function for the following R code in Lattice package. I want to plot a grouped box plots (grouped by two factors). g - rep.int(c(A, B, C, D), 125) t - rnorm(5000) a - sample(t, 500, replace=TRUE) b - sample(t, 500, replace=TRUE) dta - data.frame(val = sample(t,1000), g = gl(4, 250, labels=c(A, B, C, D)) , G2 = gl(2,1, labels=c(XX, YY))) # ggplot2 package required p - ggplot(dta, aes(factor(G2), val)) p + geom_boxplot(aes(fill = factor(g))) Any suggestion would be highly appreciated! Gary [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] shared axes in multipanel plot
I think the basic problem is that you are bringing in new data from outside the xyplot() call -- i.e `b2` and `baseline` -- and are then trying to plot that against the panel argument `x`. This is asking for trouble, as you have found, because `x` as passed to the panel function is modified by grouping, conditioning or subsetting operations. If you are using outside data, it is best to define both the x and y values together. Alternatively, merge all the data into one object (a matrix in this case) and define the plot structure in the high-level plot call, so that all the data series are grouped or subsetted together. Hope that helps. -Felix 2009/12/15 Gabor Grothendieck ggrothendi...@gmail.com: One resolution of the need to go outside of pnl would be to use this line: tt - unique(x) in place of tt - time(z). That would overcome the objection that the pnl function is not self contained. On Mon, Dec 14, 2009 at 3:44 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this: You seem to have found a problem. At any rate try this instead: pnl - function(x, y, ...) { tt - time(z) y - matrix(y, length(tt)) for(j in 1:ncol(y)) panel.plot.default(tt, y[,j], ...) panel.lines(tt, baseline, lwd = 2, col = grey(0.5)) panel.lines(tt, b2) } On Mon, Dec 14, 2009 at 3:19 PM, Jennifer Young jennifer.yo...@math.mcmaster.ca wrote: On Mon, Dec 14, 2009 at 11:30 AM, Jennifer Young jennifer.yo...@math.mcmaster.ca wrote: splendid! This worked well, but there are two oddities that I can't resolve. 1. In the real data, the baseline is a cumulative probability plot (from simulations) rather than the straight line. The panel.lines plots this curve, but seems to join the first and last points together. panel.points(x, baseline, type=l) did the same. I checked that the vector is indeed sorted properly, so I'm not sure why it should connect the first point to the last. I can't reproduce the problem based on this description. sorry that was lazy of me. If you modify the code you gave me as follows (with an extra line of the sqare root of baseline, as an example) the first and last points are joined. I didn't notice this before when baseline was just a line. baseline - (1:20)/20 dat1 - matrix(baseline,20,8) dat - dat1+matrix(rnorm(20*8)/30, 20,8) b2-sqrt(baseline) pnl - function(x, ...) { panel.plot.default(x, ...) panel.lines(x, baseline, lwd = 2, col = grey(0.5)) panel.lines(x, b2) } nc - ncol(dat) screens - rep(1:(nc/2), each = 2) z - zoo(dat) colnames(z) - paste(Group, screens) xyplot(z, screens = screens , layout = c(2, 2), col = black, lty = 2, scales = list(y = list(relation = same)), panel = pnl) 2. The screens are correctly labeled, but in the wrong order (left to right, top to bottom: 3,4,1,2). Is this easily corrected? xyplot(..., as.table = TRUE) will give one reordering. Another possibility is: plt - xplot(...) plt[ix] where ix is a permutation of 1:4 as.table=TRUE did the trick thanks. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] plot merging/compression with R
Hi, If your PDFs are huge, I suggest you use a different type of plot that does not explicitly plot millions of data points, but rather produces some sort of summary. Examples are box plots, or hexagonal binning (hexbin package). -Felix 2009/12/14 Walther, Alexander awaltherm...@googlemail.com: Dear list, i just encountered a problem concerning the export of multiple plots. is it possible to merge several PNGs into one PDF document? i know that this could be easily done by pdf(), but the outcome of this is /way/ too huge ( 15 MB, four plots) and to my knowledge there's no way to compress PDFs directly in R. Hence the PNGs that are saved one at a time and afterwards merged by Adobe Acrobat. Since i would like to automatize this process, can this be done by R? Alternatively, is there a way to compress a PDF of multiple pages right away? cheers Alex __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Label individual points in lattice by and ID
If you want to plot each point as the text of its ID, use a panel function: panel = function(x, y, groups, subscripts, ...) panel.text(x, y, groups[subscripts]) If you want to add labels interactively to selected points: xyplot(y~x | f1 + f2, groups=ID,dat) ## repeat for each panel: trellis.focus(); panel.identify(); trellis.unfocus() 2009/12/7 Pat Schmitz pschm...@illinois.edu: Sorry. My previous code didn't quite display my problem correctly. To make my point more clear, I want to use my groups as the label for the point, or rather the point itself. The key becomes illegible with many groups. x-as.factor(1:5) y-rnorm(1:10) f1-c(a,b) f2-c(x,y) dat-expand.grid(x=x, y=y, f1=f1, f2=f2) dat$ID - 1:dim(dat)[1] xyplot(y~x | f1 + f2, groups=ID,dat) xyplot(y~x | f1 + f2, groups=ID,auto.key=TRUE,dat) # more accurate rep of problem with key Thanks Pat On Sun, Dec 6, 2009 at 9:58 PM, Pat Schmitz pschm...@illinois.edu wrote: I am using a plot to inspect data points, and I would like to identify each point with respect to an ID. At issue is that I am producing a faceted plot with many IDs (96) and the key is far to large to accurately identify points by color. 1) Can you direct me on labeling or printing data points by an ID instead of a point, as in ID in this toy example 2) alternately is there method for printing a key for each panel which shows only those IDs which appear in the panel at hand? x-as.factor(1:5) y-rnorm(1:10) ID-1:5 f1-c(a,b) f2-c(x,y) dat-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2) xyplot(y~x | f1 + f2, dat) Thanks Pat -- Patrick Schmitz Graduate Student Plant Biology 1206 West Gregory Drive RM 1500 -- Patrick Schmitz Graduate Student Plant Biology 1206 West Gregory Drive RM 1500 [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Label individual points in lattice by and ID
xyplot(y~x | f1 + f2, data= dat, groups=ID, type=l, panel= function(x, y,groups, subscripts, ...){ panel.xyplot(x, y, groups = groups, subscripts = subscripts, ...) panel.text(x, y, groups[subscripts]) }) 2009/12/8 Pat Schmitz pschm...@illinois.edu: Thanks This works, but I lose the ability to say plot a line by group connecting the numbered points, how do I recover this, or say color the groups by ID.. xyplot(y~x | f1 + f2, data= dat, groups=ID, type=l, panel= function(x, y,groups, subscripts, ...){ panel.text(x, y, groups[subscripts]) }) Pat On Mon, Dec 7, 2009 at 3:18 AM, Felix Andrews fe...@nfrac.org wrote: If you want to plot each point as the text of its ID, use a panel function: panel = function(x, y, groups, subscripts, ...) panel.text(x, y, groups[subscripts]) If you want to add labels interactively to selected points: xyplot(y~x | f1 + f2, groups=ID,dat) ## repeat for each panel: trellis.focus(); panel.identify(); trellis.unfocus() 2009/12/7 Pat Schmitz pschm...@illinois.edu: Sorry. My previous code didn't quite display my problem correctly. To make my point more clear, I want to use my groups as the label for the point, or rather the point itself. The key becomes illegible with many groups. x-as.factor(1:5) y-rnorm(1:10) f1-c(a,b) f2-c(x,y) dat-expand.grid(x=x, y=y, f1=f1, f2=f2) dat$ID - 1:dim(dat)[1] xyplot(y~x | f1 + f2, groups=ID,dat) xyplot(y~x | f1 + f2, groups=ID,auto.key=TRUE,dat) # more accurate rep of problem with key Thanks Pat On Sun, Dec 6, 2009 at 9:58 PM, Pat Schmitz pschm...@illinois.edu wrote: I am using a plot to inspect data points, and I would like to identify each point with respect to an ID. At issue is that I am producing a faceted plot with many IDs (96) and the key is far to large to accurately identify points by color. 1) Can you direct me on labeling or printing data points by an ID instead of a point, as in ID in this toy example 2) alternately is there method for printing a key for each panel which shows only those IDs which appear in the panel at hand? x-as.factor(1:5) y-rnorm(1:10) ID-1:5 f1-c(a,b) f2-c(x,y) dat-expand.grid(x=x, y=y, id=ID, f1=f1, f2=f2) xyplot(y~x | f1 + f2, dat) Thanks Pat -- Patrick Schmitz Graduate Student Plant Biology 1206 West Gregory Drive RM 1500 -- Patrick Schmitz Graduate Student Plant Biology 1206 West Gregory Drive RM 1500 [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Patrick Schmitz Graduate Student Plant Biology 1206 West Gregory Drive RM 1500 -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] how to use different ylim scales on a lattice bwplot?
You can define a custom prepanel function: see the entry for 'prepanel' in ?xyplot If you just want to set specified ylims in each panel, you can do that by passing a list to 'ylim'. 2009/12/4 steve_fried...@nps.gov: A colleague is interested in modifying the ylim definition for individual panels of a common bwplot plotting statement. Is there an approach to modifying the bwplot function to allow for a dynamic ylim range given different panel factors ? He is using R 2.6.2 on a Linux distribution running from a CD. Thanks for the assistance. Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Lattice: multiple data sets on same plot
As a non-statistician, here is my naive method: densityplot(~ value | cat1 * cat2, xx, groups = paste(variable, which), from = 0, to = 360, bw = 100, panel = function(x, ...) panel.densityplot(c(x-360,x,x+360), ...), plot.points = FALSE, auto.key = list(columns=2), par.settings = simpleTheme(col = rep(c(red,blue), each=2), lty=1:2) Note the density is on the wrong scale now. 2009/12/4 Joel Thomas joel...@gmail.com: Thank you! Worked perfectly. Is it also possible to do the same but for circular data, for example, a density plot of circular object from the circular package using a trellis display. I have the same set of data but var1 and var2 are azimuth directions 0-360 so a standard density plot doesn't make much sense. Example data set is same as before except, pop - data.frame(var1=runif(2000, 0, 360), var2=runif(2000, 0, 360)) Thanks Joel 2009/12/3 Felix Andrews fe...@nfrac.org: library(reshape) ## the easy way xx - melt(x) head(xx) densityplot(~ value | cat1 * cat2, xx, groups = paste(variable, which), plot.points=FALSE, auto.key=list(columns=2), par.settings = simpleTheme(col = c(red,blue), lty=c(1,1,2,2))) Hint: using multiple terms in the formula as you did actually maps into the groups argument. It is generally not a good a idea to do that when you also specify groups directly. 2009/12/3 Joel Thomas joel...@gmail.com: Hi, I have two data sets; one is a population and the other a sample of that population. I am trying to plot both on the same trellis display. # Example data set with two numerical attributes and two categorical pop - data.frame(var1=rnorm(2000, 2000, 500), var2=rnorm(2000, 2000, 500)) cat-(runif(2000)=.5)+0 for(i in 1:length(cat)){ if(cat[i] == 0){ pop[i,cat1] = this } else{ pop[i,cat1] = that } } cat-(runif(2000)=.5)+0 for(i in 1:length(cat)){ if(cat[i] == 0){ pop[i,cat2] = here } else{ pop[i,cat2] = there } } #Extract sample sam - pop[sample(1:2000,50),] #Combine data sets x - make.groups(pop, sam) #Create trellis display densityplot(~var1 + var2 | cat1 * cat2, data=x, groups=which, plot.points=FALSE, auto.key=list(columns=2)) This does not produce what I want. I would like four density plots in each panel; var1 and var2 from the sample data as solid lines and var1 and var2 from the population data as dotted lines with matching colours. densityplot(~ var1 + var2 | cat1 * cat2, data=x, groups=which, panel=panel.superpose, panel.groups = function(x, y,...){ panel.densityplot(x, ...) }) ... gives the same result. I've read The panel function demystified section of the book many times and still find the panel function mystifying. Could someone please explain how to do this and also how it works. Thankyou __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] lattice: adding information on number of observations
Depends on exactly how / where you want to display the text. One approach (showing text inside each panel, at the bottom): bwplot(val ~ grp | panvar, data = dat, panel = function(x, y, ...) { panel.bwplot(x, y, ...) nn - table(x) panel.text(paste(n =, nn), x = seq_along(nn), y = current.panel.limits()$y[1], pos = 3) }) 2009/12/2 RINNER Heinrich heinrich.rin...@tirol.gv.at: Dear R-users, I am using R version 2.9.1 and lattice 0.17-26 under windows. In a lattice boxplot, I would like to add information on how many observations each singel boxplot is based upon. For example (the basic plot): # Begin R-code library(lattice) dat - data.frame(panvar = rep(c(A,B,A,B), c(3,7,4,6)), grp = rep(c(grp1, grp2), c(10,10)), val = rnorm(20)) dat bwplot(val ~ grp | panvar, data = dat) # End R-code As in my real life data the number of observations in each subgroup will be quite different, I would like to include the number of observations each boxplot is based upon. Aggregation will tell me the numbers: # Begin R-code aggregate(dat$val, by = list(dat$panvar, dat$grp), FUN = length) # End R-code But how to match these numbers with the plot (so that for example n=3 will be written as text beneath panel A/group1)? Any advice would be appreciated; kind regards Heinrich. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Help: barchart() {Lattice}
2009/12/3 Peng Cai pengcaimaill...@gmail.com: Hi R Users, I'm using following data/code (data is attached also) to produce a stacked barplot. # Sample Data: Names Col1 Col2 Col3 Row1 -20 40 -10 Row2 30 -20 40 Row3 30 10 -20 Row4 20 20 -10 # R Code: dta-read.table(data.txt, header=TRUE, row.names=Names) barchart(data.matrix(dta), horizontal=FALSE, stack=TRUE, par.settings = simpleTheme(col = 3:5), auto.key=list(space=right), border=NA ) I need help with: 1. How can I remove the (y-axis) tick marks on the right side of the plot. Since you only have one panel, try scales = free 2. While reading in the data, I'm using row.names=Names. Can I generalize this? What I mean is if for some other data set, the row names column has some other name (say Names2) or may be just blank. Can I still produce a similar graph plotting row labels (in this case they are Row1, Row2, ...) on x-axis. row.names can be a column number (1) See ?read.table It also describes the behaviour when the row names column is blank. Any help would be appreciated, Thanks, Peng __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Lattice: multiple data sets on same plot
library(reshape) ## the easy way xx - melt(x) head(xx) densityplot(~ value | cat1 * cat2, xx, groups = paste(variable, which), plot.points=FALSE, auto.key=list(columns=2), par.settings = simpleTheme(col = c(red,blue), lty=c(1,1,2,2))) Hint: using multiple terms in the formula as you did actually maps into the groups argument. It is generally not a good a idea to do that when you also specify groups directly. 2009/12/3 Joel Thomas joel...@gmail.com: Hi, I have two data sets; one is a population and the other a sample of that population. I am trying to plot both on the same trellis display. # Example data set with two numerical attributes and two categorical pop - data.frame(var1=rnorm(2000, 2000, 500), var2=rnorm(2000, 2000, 500)) cat-(runif(2000)=.5)+0 for(i in 1:length(cat)){ if(cat[i] == 0){ pop[i,cat1] = this } else{ pop[i,cat1] = that } } cat-(runif(2000)=.5)+0 for(i in 1:length(cat)){ if(cat[i] == 0){ pop[i,cat2] = here } else{ pop[i,cat2] = there } } #Extract sample sam - pop[sample(1:2000,50),] #Combine data sets x - make.groups(pop, sam) #Create trellis display densityplot(~var1 + var2 | cat1 * cat2, data=x, groups=which, plot.points=FALSE, auto.key=list(columns=2)) This does not produce what I want. I would like four density plots in each panel; var1 and var2 from the sample data as solid lines and var1 and var2 from the population data as dotted lines with matching colours. densityplot(~ var1 + var2 | cat1 * cat2, data=x, groups=which, panel=panel.superpose, panel.groups = function(x, y,...){ panel.densityplot(x, ...) }) ... gives the same result. I've read The panel function demystified section of the book many times and still find the panel function mystifying. Could someone please explain how to do this and also how it works. Thankyou __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Help: barchart() {Lattice}
2009/12/3 Peng Cai pengcaimaill...@gmail.com: Hi Felix, Thanks for your help. If I'm defining my own y-scales like the one in R code below, then can I remove right side tick marks? Yes. Look at the description of the scales argument in ?xyplot dta-read.table(data.txt, header=TRUE, row.names=Names) library(lattice) yScale - seq(-200, 200, 10) barchart(data.matrix(dta), horizontal=FALSE, stack=TRUE, par.settings = simpleTheme(col = 3:5), auto.key=list(space=right), border=NA, scales = list(y = list(at = yScale)) ) Thanks, Peng On Wed, Dec 2, 2009 at 5:44 PM, Felix Andrews fe...@nfrac.org wrote: 2009/12/3 Peng Cai pengcaimaill...@gmail.com: Hi R Users, I'm using following data/code (data is attached also) to produce a stacked barplot. # Sample Data: Names Col1 Col2 Col3 Row1 -20 40 -10 Row2 30 -20 40 Row3 30 10 -20 Row4 20 20 -10 # R Code: dta-read.table(data.txt, header=TRUE, row.names=Names) barchart(data.matrix(dta), horizontal=FALSE, stack=TRUE, par.settings = simpleTheme(col = 3:5), auto.key=list(space=right), border=NA ) I need help with: 1. How can I remove the (y-axis) tick marks on the right side of the plot. Since you only have one panel, try scales = free 2. While reading in the data, I'm using row.names=Names. Can I generalize this? What I mean is if for some other data set, the row names column has some other name (say Names2) or may be just blank. Can I still produce a similar graph plotting row labels (in this case they are Row1, Row2, ...) on x-axis. row.names can be a column number (1) See ?read.table It also describes the behaviour when the row names column is blank. Any help would be appreciated, Thanks, Peng __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Help: barchart() {Lattice}
Either (1) use the 'alternating' option rather than 'relation' (see documentation for 'scales' argument); or (2) put 'rot' inside the 'y' list if you want it to apply only to the y axis. 2009/12/3 Peng Cai pengcaimaill...@gmail.com: Hi Felix and Others, I just realized, after using relation=free option, my y-axis labels got rotated by 90 degree. Previously they were horizontal and now they are vertical. I tried using rot= option but it rotates both x and y-axis labels at the same time. Any suggestions, I'm trying: scales = list(relation=free, rot=90, y = list(at = yScale)) Thanks, Peng On Wed, Dec 2, 2009 at 6:17 PM, Peng Cai pengcaimaill...@gmail.com wrote: Got it thanks, (relation=free worked), more specifically scales = list(relation=free, y = list(at = yScale)) On Wed, Dec 2, 2009 at 6:04 PM, Felix Andrews fe...@nfrac.org wrote: 2009/12/3 Peng Cai pengcaimaill...@gmail.com: Hi Felix, Thanks for your help. If I'm defining my own y-scales like the one in R code below, then can I remove right side tick marks? Yes. Look at the description of the scales argument in ?xyplot dta-read.table(data.txt, header=TRUE, row.names=Names) library(lattice) yScale - seq(-200, 200, 10) barchart(data.matrix(dta), horizontal=FALSE, stack=TRUE, par.settings = simpleTheme(col = 3:5), auto.key=list(space=right), border=NA, scales = list(y = list(at = yScale)) ) Thanks, Peng On Wed, Dec 2, 2009 at 5:44 PM, Felix Andrews fe...@nfrac.org wrote: 2009/12/3 Peng Cai pengcaimaill...@gmail.com: Hi R Users, I'm using following data/code (data is attached also) to produce a stacked barplot. # Sample Data: Names Col1 Col2 Col3 Row1 -20 40 -10 Row2 30 -20 40 Row3 30 10 -20 Row4 20 20 -10 # R Code: dta-read.table(data.txt, header=TRUE, row.names=Names) barchart(data.matrix(dta), horizontal=FALSE, stack=TRUE, par.settings = simpleTheme(col = 3:5), auto.key=list(space=right), border=NA ) I need help with: 1. How can I remove the (y-axis) tick marks on the right side of the plot. Since you only have one panel, try scales = free 2. While reading in the data, I'm using row.names=Names. Can I generalize this? What I mean is if for some other data set, the row names column has some other name (say Names2) or may be just blank. Can I still produce a similar graph plotting row labels (in this case they are Row1, Row2, ...) on x-axis. row.names can be a column number (1) See ?read.table It also describes the behaviour when the row names column is blank. Any help would be appreciated, Thanks, Peng __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Implementation of the Shuffled Complex Evolution (SCE-UA) Algorithm
http://code.google.com/p/ihacres/source/browse/trunk/man/SCEoptim.Rd http://code.google.com/p/ihacres/source/browse/trunk/R/sce.R source(http://ihacres.googlecode.com/svn/trunk/R/sce.R;) 2009/11/12 Hans W Borchers hwborch...@googlemail.com: Simon Seibert simon.seibert at mytum.de writes: Good evening list, I'm looking for an R implementation of the Shuffled Complex Evolution†(SCE-UA) algorithm after Duan et al. (1993). Does anybody know if there is an extension/ package existing that contains it? Thanks very much for your help! Cheers, Simon I am looking into stochastic global optimization routines, such as variants of genetic algorithms (GA), particle swarm optimization (PSO), and shuffled complex (SCE) or differential evolution (DE). At the moment I am testing a free Matlab implementation of SCE-UA. If that turns out to be interesting and effective, I will translate it into an R function, maybe within the next few weeks -- except, of course, someone else is going to do an implementation of a similar procedure. Right now I am not totally convinced. Maybe you try your problem with other approaches available in R (see e.g. the Optimization task view). Regards Hans Werner Duan QY, Gupta KV, Sorooshian S (1993) Shuffled Complex Evolution Approach for Effective and Efficient Global Minimization. In Jour. of optimization theorie and applications. Vol 76, 3, 501-521 __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] using xyplot to plot frequencies
histogram(~ standard | Year, data = all2) 2009/11/7 Lanna Jin lanna...@gmail.com: Hi all, First off, thank you for the overwhelming response last time. I'm still trying to figure out the syntax of R to plot some distributions of some frequencies. I've managed to plot histograms from the data, but I would like to clean it up using xyplot from library(lattice). Unfortunately I cannot find a solution to my problem. Given a dataframe all2, with numerical data in cols year and standard (standard being standardized data) all2 Year standard 1 2001 0.034246575 2 2001 0.0 ... 141 2008 0.012820513 142 2008 0.230769231 I have plotted separate histograms for each year using hist(all2[Year==2001,]$standard,breaks=seq(0,.7,.005),ylim=c(0,10),main=2001,xlab=cooccured/total sites,ylab=frequency of cooccurance) hist(all2[Year==2002,]$standard, ... hist(all2[Year==2003,]$standard, ... etc. I would like to clean it up a bit by plotting the data using xyplot from library(lattice) of the standardized.data. My questions are: a. Is there a function I could use inside xyplot to graph the frequency/histogram of a given year? I tried something around the lines of, xyplot(freq(all2[Year==2001,]$standard)~(all2[Year==2001,]$standard)|all2[Year==2001]) obviously did not work. b. How would I plot the frequencies of standard for each year in xyplot? I tried converting all2 into a ftable, and from there converting it into a dataframe (freqframe) and then plotting: xyplot(freqframe$Freq~freqframe$standard|freqframe$Year) the plot is wrong, probably because the dataframe has unnecessary repeats of values. I also tried converting all2 into a ftable (also tried a matrix) and naming the columns and rows and evoking them in the xyplot. But this has also turned disasterous. Thanks in advance! -- Lanna Jin lanna...@gmail.com 510-898-8525 [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] xyplot help - colors and break in plot
2009/9/29 Tim Clark mudiver1...@yahoo.com: Dear List, I am new to lattice plots, and am having problems with getting my plot to do what I want. Specifically: 1. I would like the legend to have the same symbols as the plot. I tried simpleKey but can't seem to get it to work with autoKey. Right now my plot has dots (pch=19) and my legend shows circles. Rather than the pch = 19 argument, use par.settings = simpleTheme(pch = 19, cex = .4) 2. I have nine groups but xyplot seems to only be using seven colors, so two groups have the same color. How do I get a range of nine colors? Yes, in the default theme, there are seven colours: see trellis.par.get(superpose.symbol) You can change the set of colours yourself by modifying that list (via trellis.par.set). An easier option is to use one of the predefined ColorBrewer palettes, with custom.theme() from the latticeExtra package, or just simpleTheme(). See ?brewer.pal (RColorBrewer package) You will see there are a few qualitative color palettes with 9 or more colours: e.g. brewer.pal(9, Set1) brewer.pal(12, Set3) 3. I have one group who's y range is much greater than all the others. I would like to split the plot somehow so that the bottom part shows ylim=c(0,200) and the top shows ylim=c(450,550). Is this possible? Yes... in the absence of a reproducible example, maybe something like xyplot(Area.km2 ~ DataPoint | (Area.km2 200), m.dp.area, groups = Manta, scales = list(y = free)) or AreaRange - shingle(Area.km2, rbind(c(0,200),c(450,550))) xyplot(Area.km2 ~ DataPoint | AreaRange, m.dp.area, groups = Manta, scales = list(y = free)) What I have so far is: library(lattice) xyplot(m.dp.area$Area.km2 ~ m.dp.area$DataPoint, m.dp.area, groups = m.dp.area$Manta, main = Cummulative area of 100% MCP, xlab = Data Point, ylab = MCP Area, ylim = c(0,150), scales = list(tck = c(1, 0)), #Removes tics on top and r-axis pch=19,cex=.4, auto.key = list(title = Mantas, x = .05, y=.95, corner = c(0,1),border = TRUE)) #Legend Thanks, Tim Tim Clark Department of Zoology University of Hawaii __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] multiple lattice, xyplot levelplot on same page
Ky, The error you report is a problem with the c() method for trellis plots: it allows for a different panel function in each panel, but only one prepanel function. Because of this, the prepanel.default.levelplot function is not getting what it expects to recompute the panel dimensions. It may be possible to extend the function to handle this, but for now you have a few options: (1) Set subscripts = TRUE in the xyplot: p1 - update(p1, subscripts = TRUE) update(c(p2, p1, x.same = TRUE), layout = c(1, 2)) (2) Put the xyplot first, but then re-order the panels by indexing: update(c(p1, p2, x.same = TRUE), layout = c(1, 2))[2:1] (3) Take out the x.same=TRUE argument, if you can set the x scales to be the same beforehand. In your example, the xyplot and levelplot had the same x axis limits anyway, but presumably that is not the case in your real problem. update(c(p2, p1), layout = c(1, 2)) (4) Use a completely different mechanism: draw the two plots in the desired position (after setting the x axes to be identical beforehand, if desired). See ?plot.trellis This latter mechanism was designed in to trellis from the beginning, whereas the c() method is basically a hack. It also has the advantage of retaining complete control over each plot independently. By the way, I can't understand what you are trying to do with the par.settings$layout.width argument. It doesn't seem to have any effect. Ditto for the 'y = c(1/4, 3/4))' argument. Also, I seem to have lost control of par settings such as las = 1 This is a base graphics (?par) parameter, which does not apply to grid or lattice graphics. The equivalent of las in lattice is the scales$rot argument. See ?xyplot Hope that helps -Felix 2009/9/26 Ky Mathews k.math...@usyd.edu.au: Dear R-users, I'd like to place an xyplot() at the top of a page and a levelplot() at the bottom of the same page, and have the x-axes be the same. I've come close to finding a solution through Rarchive, and can produce an upside-down version of what I'd like (levelplot() on the top - see code below). However, the following error occurs when I try and plot the xyplot() at the top: Error in prepanel.default.function(x = 0:10, y = c(0, 1, 4, 9, 16, 25, : element 1 is empty; the part of the args list of 'length' being evaluated was: (subscripts) Any pointers in the right direction would be much appreciated. #OS: Windows XP 2002 SP3; R: 2.9.2; lattice 0.17-25; latticeExtra 0.6-1 Thanks and regards, Ky ### #Rcode for xyplot and lattice plot on the same page. library(lattice) library(latticeExtra) #xyplot x1 - 0:10 x2 - x1^2 p1 - xyplot(x2 ~ x1 , par.settings = list(layout.width = list(panel=1, ylab = 2 , axis.left =1.0, left.padding=1 , ylab.axis.padding=1, axis.panel=1))) #levelplot y.df - data.frame(y1 = rep(x1, times = 3) , y2 = rep(c('E1', 'E2', 'E3'), each = length(x1)) , y3 = c(x1, x1+2, x1-1)) p2 - levelplot(y3 ~ y1*y2, data = y.df, , par.settings = list(layout.width = list(panel=1, ylab = 2 , axis.left =1.0, left.padding=1 , ylab.axis.padding=1, axis.panel=1))) #Printing the plots on the same page #This is what I found on an Rarchive post (thank-you) #it works if the levelplot (p2) is at the top of the page #i.e. update(c(p1, p2, x.same = TRUE) , layout = c(1, 2) , ylab = list(c(p1, p2) , y = c(1/4, 3/4)) , par.settings = list(layout.heights = list(panel = c(1, 1 #however, the following error appears if the order is reversed (which is what I would like) update(c(p2, p1, x.same = TRUE) , layout = c(1, 2) , ylab = list(c(p2, p1) , y = c(1/4, 3/4)) , par.settings = list(layout.heights = list(panel = c(1, 1 The following error appears: #Error in prepanel.default.function(x = 0:10, y = c(0, 1, 4, 9, 16, 25, : # element 1 is empty; # the part of the args list of 'length' being evaluated was: # (subscripts) Also, I seem to have lost control of par settings such as las = 1 #--- Dr Ky L. Mathews Co-ordinator, CIMMYT ICARDA Communications Project Research Fellow, Plant Breeding Institute, The University of Sydney, Australia __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T
Re: [R] Lattice, stripplot (xyplot), plotting data with median line, numeric x-axis
Hi David, stripplot is for numeric vs categorical data (and is a thin wrapper around xyplot). Just change stripplot to xyplot and it will work. -Felix 2009/9/27 Afshartous, David dafshart...@med.miami.edu: All, On p.52 of Deepayan Sarkar's Lattice book there is a nice plot of showing residuals with median lines superimposed or various groups: library(lattice) stripplot(sqrt(abs(residuals(lm(yield~variety+year+site ~ site, data = barley, groups = year, jitter.data = TRUE, type = c(p, a), fun = median) Suppose we wanted to make a similar plot for a numeric x-axis. Is there any way to do this with stripplot or does one have to xyplot and presumably panel functionality to get the median line? This does not work: barley$site.numeric =as.numeric(barley$site) stripplot(sqrt(abs(residuals(lm(yield~variety+year+site ~ site.numeric, data = barley, groups = year, jitter.data = TRUE, type = c(p, a), fun = median) Any tips much appreciated. For my data I had made my x-axis a factor but forgot that this doesn't work since the intervals are not equally spaced. Thanks! David __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] panel.text question
Use packet.number() to identify which data subset you are dealing with (inside the panel function): xyplot(y~x|a, panel=function(...){ panel.loess(...) panel.text(0,2,label=c('best','better','bad','worst')[packet.number()]) }) There is also panel.number() which is similar but refers to the panel position rather than data set. The difference shows up if you re-arrange the panels from the default ordering. 2009/9/27 Osman Al-Radi osman.al.r...@gmail.com: Hello, Thanks for your suggestion. It works in my simplified example. However, it didn't work in my real code. It is probably because I neglected to include the group argument in the example. I apologize for that. Below is the real code, if you need the actual data I can include it too. # this works well xyplot(PaCO2~time|group, group=animal,layout=c(3,1,1),aspect=1, panel=function(...){ panel.loess(...) panel.superpose(...)} ,data=pig,subset=time5 time181, xlab='Time (minutes)', ylab='PaCO2 (mmHg)') # this gives the following error Error in using packet 1 data, X argument missing with no #default in each of the plot panel xyplot(PaCO2~time|group, group=animal,layout=c(3,1,1),aspect=1, panel=function(x,y,subscripts,...){ panel.loess(...) panel.superpose(...) panel.text(100,110,label=c(' ','p=0.007','p=0.006')[tail(subscripts, 1)])} ,data=pig, subset=time5 time181, xlab='Time (minutes)', ylab='PaCO2 (mmHg)') Thanks tremendously for your help. I don't know why its soo hard just to add some text! Osman Osman O. Al-Radi, MD, MSc, FRCSC Staff Cardiovascular Surgeon Co-medical director, Tissue Bank The Hospital for Sick Children University of Toronto, Canada On Thu, Sep 24, 2009 at 2:18 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: xyplot(y ~ x | a, panel=function(x, y, subscripts, ...){ panel.loess(x, y) panel.text(0, 2, label=c('best','better','bad','worst')[tail(subscripts, 1)/100]) }) On Thu, Sep 24, 2009 at 2:45 PM, Osman Al-Radi osman.al.r...@gmail.com wrote: Dear R-help, I would like to add text to each of four panels in a plot generated by xyplot in lattice library. A sample code is given below, the plot generated has the first label repeated in all panels! How can I get the labels to be different in each panel? library(lattice) x - rnorm(400) y - rnorm(400) a - gl(4, 100) xyplot(y~x|a, panel=function(...){ panel.loess(...) panel.text(0,2,label=c('best','better','bad','worst'))}) Thanks Osman Osman O. Al-Radi, MD, MSc, FRCSC Staff Cardiovascular Surgeon Co-medical director, Tissue Bank The Hospital for Sick Children University of Toronto, Canada [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] superimposing xyplots on same scale
Um, no, please use doubleYScale() in latticeExtra, rather than as.layer(). However, in your case, why don't you just do a standard lattice plot like xyplot(time_pct + pct_compl ~ date, par.settings = simpleTheme(col = c(blue, red)), type=b, pch=15, ...) If you gave a reproducible example I could give you a reproducible solution. Cheers -Felix 2009/9/24 baptiste auguie baptiste.aug...@googlemail.com: Hi, try ?as.layer in the latticeExtra package. HTH, baptiste 2009/9/24 Larry White ljw1...@gmail.com: I have two xyplots that i want to superimpose (code below). By default they are displayed on slightly different y scales (one runs from 10 to 25, the other from 10 to 30). I would like to force them both onto the same scale (10 to 30) so the relation between the two is clear. Is there a way to do this? thanks much pct_compl_chart - xyplot(pct_compl ~ date, col=red, type=b, pch=15, scalse=list(tick.number=5), ylab=list(label=Pct. Compl.), layout=c(1,5), xlab=list(label=), between = list(x = c(0, 0, 0), y = c(8,-10,-10,-10,-10)) ) time_pct_chart - xyplot(time_pct ~ date, col=blue, type=b, pch=15, scales=list(tick.number=5), ylab=list(label=), layout=c(1,5), xlab=list(label=), between = list(x = c(0, 0, 0), y = c(8,-10,-10,-10,-10)) ) [[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. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] superimposing xyplots on same scale
Sorry, doubleYScale is not appropriate, since you specifically want a common y scale. I think Baptiste was suggesting to use layer(), rather than as.layer(): something like xyplot(pct_compl ~ date, col=red, ...) + layer(panel.xyplot(date, time_pct, col = blue)) But again, I would definitely recommend you do this with the standard lattice interface in xyplot: use the 'groups' argument, or (equivalently) specify two series in the formula. -Felix 2009/9/25 Felix Andrews fe...@nfrac.org: Um, no, please use doubleYScale() in latticeExtra, rather than as.layer(). However, in your case, why don't you just do a standard lattice plot like xyplot(time_pct + pct_compl ~ date, par.settings = simpleTheme(col = c(blue, red)), type=b, pch=15, ...) If you gave a reproducible example I could give you a reproducible solution. Cheers -Felix 2009/9/24 baptiste auguie baptiste.aug...@googlemail.com: Hi, try ?as.layer in the latticeExtra package. HTH, baptiste 2009/9/24 Larry White ljw1...@gmail.com: I have two xyplots that i want to superimpose (code below). By default they are displayed on slightly different y scales (one runs from 10 to 25, the other from 10 to 30). I would like to force them both onto the same scale (10 to 30) so the relation between the two is clear. Is there a way to do this? thanks much pct_compl_chart - xyplot(pct_compl ~ date, col=red, type=b, pch=15, scalse=list(tick.number=5), ylab=list(label=Pct. Compl.), layout=c(1,5), xlab=list(label=), between = list(x = c(0, 0, 0), y = c(8,-10,-10,-10,-10)) ) time_pct_chart - xyplot(time_pct ~ date, col=blue, type=b, pch=15, scales=list(tick.number=5), ylab=list(label=), layout=c(1,5), xlab=list(label=), between = list(x = c(0, 0, 0), y = c(8,-10,-10,-10,-10)) ) [[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. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Zoomable graphs with multiple plots
There is also playwith, if you're willing to go down the GTK+ route... 2009/9/3 Tim Shephard tsheph...@gmail.com: Hi folks, I was wondering if anyone could confirm/deny whether there exists any kind of package to facilitate zoomable graphs with multiple plots (eg, plot(..) and then points(..)). I've tried zoom from IDPmisc, and iplot from the iplot and iplot extreme packages, but as far I can tell, neither can handle the task. Does anyone know anything else that might work? Or generally know different? Cheers, Tim. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Two lines, two scales, one graph
2009/8/25 David Winsemius dwinsem...@comcast.net On Aug 24, 2009, at 11:00 AM, Rick wrote: I would like to plot two variables against the same abscissa values. They have different scales. I've found how to make a second axis on the right for labeling, but not how to plot two lines at different scales. After using R site search I would ask: have you looked at as.layer in {latticeExtra}? Don't use as.layer(). For this purpose it has been replaced by doubleYScale(), also in the latticeExtra package. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Two lines, two scales, one graph
2009/8/25 David Winsemius dwinsem...@comcast.net: On Aug 24, 2009, at 7:01 PM, Felix Andrews wrote: 2009/8/25 David Winsemius dwinsem...@comcast.net On Aug 24, 2009, at 11:00 AM, Rick wrote: I would like to plot two variables against the same abscissa values. They have different scales. I've found how to make a second axis on the right for labeling, but not how to plot two lines at different scales. After using R site search I would ask: have you looked at as.layer in {latticeExtra}? Don't use as.layer(). For this purpose it has been replaced by doubleYScale(), also in the latticeExtra package. Interesting. I just downloaded lattice Extra from CRAN this afternnon intending to look for doubleYscale and could not find it. So I looked for a substitute: other attached packages: [1] latticeExtra_0.5-4 The current version of latticeExtra is 0.6-1, but you have 0.5-4 installed. See: http://cran.r-project.org/web/packages/latticeExtra/ [[ For the record, the function is called doubleYScale not doubleYscale. ]] sessionInfo() R version 2.9.1 Patched (2009-07-04 r48897) x86_64-apple-darwin9.7.0 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] latticeExtra_0.5-4 lattice_0.17-25 RColorBrewer_1.0-2 Design_2.1-2 [5] survival_2.35-4 Hmisc_3.5-2 plotrix_2.5-4 loaded via a namespace (and not attached): [1] cluster_1.12.0 grid_2.9.1 tools_2.9.1 David Winsemius, MD Heritage Laboratories West Hartford, CT -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Problem with RGtk2 Rattle
Um, it sounds as if you are trying to install glade-3.4.3-win32.zip into R as a package... but it is not an R package!! GTK+/Glade is a system library to be installed into Windows. You should download the .exe (not the .zip) http://downloads.sourceforge.net/gladewin32/gtk-dev-2.12.9-win32-2.exe and run it to install it. By the way, problems with rattle are best sent to the rattle-users mailing list: http://groups.google.com/group/rattle-users -Felix 2009/8/1 Wayne Murray wayne.mur...@medicareaustralia.gov.au: HI Thanks for all the advice, unfortunately I am unable to install the suggested fix - error message as follows: Error in gzfile(file, r) : cannot open the connection In addition: Warning message: In gzfile(file, r) : cannot open compressed file 'glade-3.4.3-win32-1/DESCRIPTION', probable reason 'No such file or directory' Sorry but nothing seems to work Regards Wayne Felix Andrews wrote: This error comes from using an old version of the GTK+ libraries. Download the latest version for Windows from http://gladewin32.sourceforge.net/ -Felix 2009/7/31 Graham Williams graham.willi...@togaware.com: Hi Wayne - but what version of the other tools have you installed? Regards, Graham 2009/7/30 Wayne Murray wayne.mur...@medicareaustralia.gov.au HI Graham Thanks for responding so promptly - unfortunately downloading and running this new version of Rattle did not alter the outcome - I am however running on Windows XP Regards Wayne Wayne Murray wrote: HI Apologies for previously trying to post this question onto the Dev forum. I have recently update my versions of R and related packages. When I try to use rattle the following message appears Error in .RGtkCall(R_setGObjectProps, obj, value, PACKAGE = RGtk2) : Invalid property tooltip-text! I have downloaded and installed the latest available version of RGtk2, so I am at a loss to explain this error, or more importantly what I need to do to overcome it Thanks for any suggestions Regards Wayne - Dr D. W. Murray Canberra, Australia -- View this message in context: http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24736985.html Sent from the R help mailing list archive at Nabble.com. __ 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. [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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. - Dr D. W. Murray Canberra, Australia -- View this message in context: http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24768229.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Problem with RGtk2 Rattle
This error comes from using an old version of the GTK+ libraries. Download the latest version for Windows from http://gladewin32.sourceforge.net/ -Felix 2009/7/31 Graham Williams graham.willi...@togaware.com: Hi Wayne - but what version of the other tools have you installed? Regards, Graham 2009/7/30 Wayne Murray wayne.mur...@medicareaustralia.gov.au HI Graham Thanks for responding so promptly - unfortunately downloading and running this new version of Rattle did not alter the outcome - I am however running on Windows XP Regards Wayne Wayne Murray wrote: HI Apologies for previously trying to post this question onto the Dev forum. I have recently update my versions of R and related packages. When I try to use rattle the following message appears Error in .RGtkCall(R_setGObjectProps, obj, value, PACKAGE = RGtk2) : Invalid property tooltip-text! I have downloaded and installed the latest available version of RGtk2, so I am at a loss to explain this error, or more importantly what I need to do to overcome it Thanks for any suggestions Regards Wayne - Dr D. W. Murray Canberra, Australia -- View this message in context: http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24736985.html Sent from the R help mailing list archive at Nabble.com. __ 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. [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] How to read a specific dataset, not the entire data, from HDF5?
Hi DH I recommend the rgdal package, which provides R bindings for the Geospatial Data Abstraction Library (GDAL). This does handle HDF5, according to the list at http://www.gdal.org/formats_list.html I have not ever used HDF5 myself, but that it what I would try. -Felix 2009/6/27 Daehyok Shin sdh...@gmail.com: Hi. Recently I am working for a project to generate massive numeric data. After storing them in HDF5 using PyTables, we are trying to use R for data analysis and visualisation. Surprising to me, however, I could not find a R package to allow the reading of a specific dataset (or its slide) in a HDF5 file. I found I can read and write only the entire data using hdf5 package and I could not locate rhdf5 in bioconductor. Each dataset is huge, so selecting a specific dataset is a mandatory function for my project. Could you give me a hint for the solution? Thanks. -- DH __ 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. -- Felix Andrews / 安福立 Post-Doctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 1670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ 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.
Re: [R] Lattice question.
Modifying your example... library(lattice) set.seed(42) XX - data.frame(y=runif(300,0,10),a=factor(sample(letters[1:3],300, TRUE,c(0.5,0.3,0.2 XX - rbind(XX,XX) XX$gps - rep(c(count,percent),each=300) print(histogram(~y|a*gps,as.table=TRUE,data=XX, panel=function(x,...,type) { panel.histogram(x,...,type=c(count,percent)[current.row()]) } )) but the use of current.row() breaks if the layout changes. Also, the y scales are the same here for count and percent data, which may not be appropriate. You may have to set the y scales for each panel explicitly. Or, another option is: a - histogram(~y|a, data = XX, subset = gps==count, type=count) b - histogram(~y|a, data = XX, subset = gps==density, type=density) library(latticeExtra) update(c(count=a, density=b), layout=c(3,2), ylab=c(count, density)) 2009/3/30 Rolf Turner r.tur...@auckland.ac.nz: Hi. I am trying to do histograms in lattice, and I want to get both counts and percents in the same plot. To try to be clearer --- there are 3 levels to my factor; I'd like to get a 2 x 3 array of plots where the top row consist of histograms by counts and the bottom consists of (the corresponding) histograms by percent. I tried the following: # Demo. library(lattice) set.seed(42) XX - data.frame(y=runif(300,0,10),a=factor(sample(letters[1:3],300, TRUE,c(0.5,0.3,0.2 XX - rbind(XX,XX) XX$gps - rep(c(1,2),each=300) print(histogram(~y|a*gps,as.table=TRUE,data=XX, panel=function(x,...,type) { panel.histogram(x,...,type=c(count,percent)[gps]) } )) But I got 2 x 3 array of plots each containing only the text string ``Error using packet 1, ..., 6 object gps not found.'' I tried various other fiddle-arounds and got nowhere. Is it possible to do what I want? If so, how? Thanks. cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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. -- Felix Andrews / 安福立 mobile: +61_410400963 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ 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.
Re: [R] Where to find the source codes for the internal function in stats package
I guess you have the binary distribution, not the R source code. The functions you want seem to be defined in the files dchisq.c and dnchisq.c in https://svn.r-project.org/R/trunk/src/nmath/ 2009/1/17 zhijie zhang rusers...@gmail.com: Dear all, I want to see the source codes for dchisq(x, df, ncp=0, log = FALSE), but cannot find it. I input dchisq in the R interface, and then enter, the following message return: dchisq /*/ function (x, df, ncp = 0, log = FALSE) { if (missing(ncp)) .Internal(dchisq(x, df, log)) else .Internal(dnchisq(x, df, ncp, log)) } environment: namespace:stats /*/ It seems that dchisq() is the internal function in STATS package. So go to C:\Program Files\R\R-2.7.2\library\stats to look for it. I browsed the files in this catalog, but it seems that i missed it. Anybody can tell me how and where to find the codes, Thanks a lot. [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ 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.
Re: [R] misalignment of x-axis when overlaying two plots using latticeExtra
Hi Sean, as.layer() does not do what you think it does: it does not attempt to plot things on a common scale, it simply draws the panels of two lattice plots in the same space. Actually, it is not very useful on its own. What you want is doubleYScale() in the development version (0.5-5) of latticeExtra. You can install it with install.packages(latticeExtra, repos=http://R-Forge.R-project.org;) then doubleYScale(barchart.obj, dot.outcome) By the way, wise persons say plotting on multiple scales is often a bad idea. I would at least make sure both axes start from zero. -Felix 2009/1/15 Sean Zhang seane...@gmail.com: Dear R-helpers: I am an entry-level R user and have a question related to overlaying a barchart and and a xyplot using latticeExtra. My problem is that when I overlay them I fail to align their x-axes. I show my problem below through an example. #the example data frame is provided below vec -c(1,5.056656,0.5977967,0.06126587,0.08557778, 2,4.601049,0.5995989,0.05002188,0.11410027, 3,4.932008,0.5502283,0.06727938,0.12531825, 4,4.763798,0.5499489,0.06473846,0.10752641, 5,4.944967,0.5328129,0.05445327,0.13663951, 6,5.063504,0.5267245,0.06477738,0.12380332, 7,4.735251,0.5528205,0.06851714,0.12196075, 8,5.141733,0.5304151,0.07965567,0.15123277, 9,5.215678,0.5219224,0.06694207,0.16476356, 10,4.930439,0.5712519,0.08591549,0.09710933, 11,5.075990,0.5615573,0.05778996,0.15361845, 12,4.909847,0.5683740,0.08711699,0.11189277, 13,4.863164,0.5652511,0.0727,0.12071060, 14,5.173818,0.5564918,0.09830620,0.11831926, 15,4.762325,0.5345888,0.08792658,0.11738642, 16,5.046225,0.5268459,0.09574746,0.13254236, 17,4.902188,0.5370394,0.07194955,0.13164327, 18,4.865935,0.5446562,0.06894994,0.12645103, 19,5.204060,0.5650887,0.06726925,0.09242551, 20,5.208138,0.5765187,0.09282935,0.11053842) df-as.data.frame( t(matrix(vec,nrow=5,ncol=20))) names(df)-c(group,outcome,proportion_1,proportion_2,proportion_3) library(latticeExtra) library(lattice) #First generate barchart to plot the 3 proportions prop.data -subset(df,select=c(proportion_1,proportion_2,proportion_3)) prop.tab - as.table(as.matrix(prop.data)) barchart.obj-barchart(prop.tab, stack=TRUE, horizontal = FALSE) #Second, generate the dots of outcome (I could have used type=l but using type=p makes the #misalignment of x-axis more obvious. dot.outcome - xyplot(outcome~group,df,type=p, col=blue) #Last, overlay the two plots barchart.obj+ as.layer(dot.outcome,style=2,axes=c(y), outside=TRUE) #Now, you should be able to see the x-axis of the two plots are not matching. #i.e., a dot is not at the center of its correspoding bar. How can I fix this? Your help will be highly appreciated. Many thanks in advance. -Sean [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ 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.
Re: [R] Trouble with 'smooth' using xyplot in lattice
Peter, The error message comes from panel.loess, which is the panel function that draws the Loess smoothing line. It means one of your groups has too few data points or is too clustered in its domain for the Loess smoother to converge. You could - give up on the pretty-looking smoother - increase the span; or - ignore the error, with eg lattice.options = list(panel.error = warning) In any case I would recommend plotting the data points, not just the smoothed lines. You can set type = c(p, smooth) -Felix 2008/12/22 lost_ri...@excite.com lost_ri...@excite.com: Hello, I am fairly new to R am stumped on how to get the xyplot function in the lattice package to produce a scatter plot of count data versus time, such that the count data represent 8 different groups, and the plot produced has 8 unique smoothed lines for the different groups. This is the closest I can get to the desired plot: xyplot(masmean ~ mas, data = Pre96CR.masmeans, groups = behavior, type = 'smooth', span = 0.3, lwd =2, xlab = Minutes After Sunrise, ylab = Behaviors at Castle key = simpleKey(levels(Pre96CR.masmeans$behavior), space = 'right')) This code produces a plot, but one level of the grouping factor ('behavior') is always absent from the plot and in the middle of the plot I receive an error message: Error using packet 1 NA/NaN/Inf in foreign function call (arg 1) Otherwise, the plot is exactly what I want with smoothed lines produced for the 7 other levels of behavior. Thanks in advance for any ideas/suggestions. Cheers, Peter Auto Insurance Click to get a free auto insurance quotes from top companies. http://tagline.excite.com/fc/BK72PcZaarRjzT3NanuZSqmiJRbhpHy3XCE7MhKHfzwJU7fMMxfSz2/ [[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. -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ 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.