Re: [R] textbox in lattice

2010-06-01 Thread baptiste auguie
o) > > Would you call the gridExtra command before the xyplot command or after? > > Now I have: > > temp <- as.mcmc(foo) > xyplot(temp, layout=c(2,11), main="plot title") > > > THANKS!! > > > On 6/1/10 11:35 AM, baptiste auguie wrote: >> Hi, &

Re: [R] textbox in lattice

2010-06-01 Thread baptiste auguie
ll take up 3 times more space in the vertical direction than the table. For more control, see ?grid.layout ?viewport etc. baptiste > > Thanks a million! > > -N > > > On 6/1/10 12:07 PM, baptiste auguie wrote: >> Please do read the posting guide, in particular regarding r

Re: [R] Faster union of polygons?

2010-06-01 Thread baptiste auguie
Hi, I think you could use a concave hull from the alphahull package, http://yihui.name/en/2010/04/alphahull-an-r-package-for-alpha-convex-hull/ It may be difficult to find the right parameters if the polygons differ widely in edge lengths, though. HTH, baptiste On 2 June 2010 03:53, Remko Du

Re: [R] textbox in lattice

2010-06-02 Thread baptiste auguie
On 2 June 2010 07:55, Deepayan Sarkar wrote: > > > Something like this should also work, except that the grob produced by > tableGrob() doesn't seem to know its height. Indeed, I have not been successful in writing good widthDetails/heightDetails methods for this grob since all the drawing calcul

Re: [R] textbox in lattice

2010-06-02 Thread baptiste auguie
Hi, On 3 June 2010 05:26, Paul Murrell wrote: > Or the same drawing calculations have to be repeated within > width/heightDetails - those methods should get run within the same graphical > context as the drawDetails method. > Yes, the idea crossed my mind, but I did not find it very appealing (

Re: [R] Greek letters and formatted text

2010-06-05 Thread baptiste auguie
Try text(0.8,1,bquote("<"*sigma*">"==.(round(m,2))*"±"*.(round(sig,2 ?bquote ?plotmath On 5 June 2010 11:36, Thomas Bschorr wrote: > Hi, > > I desperately try to do s.th. like > > m=1.23455 > sig=0.84321 > > plot(1,1) > > text(0.8,1,sprintf("=%1.2f±%1.2f",m,sig)) > > where actually the gree

Re: [R] lattice::panel.levelplot.raster too picky with unequal spacing

2010-06-05 Thread baptiste auguie
", "#FFA100", "#FF3100", "#FF") pdf("colortest.pdf") colorStrip(cols, raster=T, direction="vertical") grid.newpage() colorStrip(cols, raster=F, direction="vertical") grid.newpage() colorStrip(cols, raster=T, direction="horizonta

Re: [R] textbox in lattice

2010-06-06 Thread baptiste auguie
y avoiding such duplication of calculations at drawing time), or do they have to be completely independent in the implementation? Best, baptiste On 3 June 2010 07:58, baptiste auguie wrote: > Hi, > > On 3 June 2010 05:26, Paul Murrell wrote: > >> Or the same drawing calculations ha

Re: [R] Loading an image/picture (png/jpeg/...) to screen...

2010-06-06 Thread baptiste auguie
Hi, Try this, library(png) example(readPNG) HTH, baptiste On 6 June 2010 13:46, oliver wrote: > Hello, > > > how can I load an external picture/image file to screen? > > I want to use locator() then to get coordinates of that picture... > ...in other words I want to use R to do some measureme

Re: [R] Creating pdf report

2010-06-06 Thread baptiste auguie
Hi, ggplot2 and lattice also provide convenient ways to arrange multiple plots on a page. For tables, there's also a function based on Grid graphics in the gridExtra package. A typical dummy example might be, library(ggplot2) library(gridExtra) p = qplot(Sepal.Length, Petal.Length, data=iris, c

Re: [R] Loading an image/picture (png/jpeg/...) to screen...

2010-06-06 Thread baptiste auguie
On 7 June 2010 01:16, Oliver wrote: > baptiste auguie googlemail.com> writes: > >> >> Hi, >> >> Try this, >> >> library(png) >> example(readPNG) > [...] > > > If "rasterImage" would be available, I think this would be the

Re: [R] drawing curve

2010-06-10 Thread baptiste auguie
The OP asked for a smooth curve, foo = splinefun(x,y) curve(foo, min(x), max(x)) # points(x,y) I'm sure a R wizard could make it a one-liner. HTH, baptiste On 10 June 2010 16:48, Mario Valle wrote: > x<-c(1:6) > y<-c(.01,.09,.08,.03,.001,.02) > plot(x,y, type='l') > > Please try ?plot before

Re: [R] Order labels in qplot() - ggplot2 {help}

2010-06-10 Thread baptiste auguie
Hi, You could reorder the factor levels before plotting, x$n = factor(x$n, levels=c("va","vp", letters[1:3])) last_plot() %+% x or you could avoid using factors in the first place, x <- data.frame(cbind(n,p,pm,pn), stringsAsFactors=FALSE) last_plot() %+% x HTH, baptiste On Thu, Jun 10, 20

[R] rgl: draw multiple ellipsoids

2011-01-31 Thread baptiste auguie
Dear list, I'm trying to visualise some ellipsoidal shapes in 3D. Their position, axes, and angular orientation can be arbitrary. I saw an ellipse3d function in rgl; however it is heavily oriented towards the statistical concept of ellipse of confidence, whilst I am just concerned with the geometr

Re: [R] rgl: draw multiple ellipsoids

2011-02-03 Thread baptiste auguie
les[ii,1],angles[ii,2],angles[ii,3], ...)) shapelist3d(ll,...) } N <- 100 set.seed(123) positions <- matrix(rnorm(3*N), ncol=3) sizes <- matrix(runif(3*N, 0.01, 0.05), ncol=3) angles <- matrix(runif(3*N, 0, 2*pi), ncol=3) system.time(rgl.ellipsoids2(positions, sizes, angles,

Re: [R] Multiple line-plots from one data file using factor

2011-02-04 Thread baptiste auguie
Hi, It's a piece of cake with ggplot, d <- read.table(textConnection("id x y 1 10 500 1 15 300 1 23 215 1 34 200 2 5400 2 13 340 2 15 210 3 10 200 3 12 150 3 16 30"), head=TRUE) str(d) library(ggplot2) p <- ggplot(d) + geom_path(aes(x,y, group=id)) p ## grouping with

Re: [R] image() with a vector

2011-02-15 Thread baptiste auguie
Hi, rasterImage may alleviate the pdf artefacts in the viewer. This seems to produce a similar output, plot(range(x),range(y), t="n") rasterImage(t(rgb(colorRamp(heat.colors(7))(z/max(z))/255)), min(x),min(y),max(x),max(y), interpolate=FALSE) HTH, baptiste On 16 February 2011 05:43, Steven Cor

Re: [R] Find and replace all the elements in a data frame

2011-02-17 Thread baptiste auguie
Hi, You could use car::recode to change the levels of the factors, library(car) transform(x, locus1 = recode(locus1, "'A' = 'A/A' ; else = 'T/T'"), locus2 = recode(locus2, "'T'='T/T' ; 'C' = 'C/C'"), locus3 = recode(locus3, "'C'='C/C' ; 'G' = 'G/G'")) HTH

Re: [R] ggplot2 directional line type?

2011-02-22 Thread baptiste auguie
Hi, You could add arrows with geom_segment; however if you want even spacing along the path it might get tricky, library(ggplot2) d <- data.frame(x=seq(0, 10, length=100), y=sin(seq(0, 10, length=100))) N <- 10 dN <- 2 ind <- seq(1,nrow(d),by=N) ind <- ind[-c(1,length(ind))]

Re: [R] Creating a .png with just an expression() in it

2011-03-04 Thread baptiste auguie
Hi, I think the easiest way is to use grid graphics, library(grid) a = 0.3 b = pi e = bquote(y[alpha] == .(a) * x[beta]+ .(round(b,2))) grid.newpage() grid.text(e) ## if you wanted a snug fit with the device window e2 = expression(integral(frac(1, alpha + x[beta])*dx, -infinity, +infinity))

[R] switch and factors

2011-03-08 Thread baptiste auguie
Dear list, Reading the help page for ?switch didn't give me more than a hint at what's going on here, x = 5 y = 2 foo <- function(a="x"){ switch(a, "x" = x, "y" = y) } foo(factor('x', levels=c('y', 'x'))) # 2 It seems that switch, when given a factor, uses the numeri

Re: [R] switch and factors

2011-03-14 Thread baptiste auguie
x', levels=c('y', 'x')) ) > [1] FALSE > > > you get > >>  as.integer( factor('x', levels=c('y', 'x')) ) > > [1] 2 > > > from the "coerced to integer" part?  Therefore the second statement (y) is > evalua

Re: [R] Scope and apply-type functions

2011-03-17 Thread baptiste auguie
Hi, I think it's a side effect of lazy evaluation, where you should probably use the ?force like a jedi, lapply(1:5,function(k){force(k) ; function(){k}})[[2]]() HTH, baptiste On 18 March 2011 07:01, jamie.f.olson wrote: > So, I've been confused by this for a while.  If I want to create funct

Re: [R] Help with plotting a line that is multicoloured based on levels of a factor

2011-03-17 Thread baptiste auguie
Hi, because each colour is defined on non-consecutive points, you'll probably need to cut the intervals to define segments around each point. One approach might be the following, d = transform(data, start = date - c(0, diff(date)/2), end = date + c(0, diff(date)/2) ) d$start.y = approx(d$date, d

Re: [R] Merging by() results back into original data frame?

2011-03-21 Thread baptiste auguie
I find it quite neat with plyr, library(plyr) ddply(d, .(group), transform, max=max(val)) HTH, baptiste On 22 March 2011 12:09, William Dunlap wrote: >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of ivo welch >> Sent: Mon

Re: [R] Pictures/ Graphics in rd-files

2011-03-29 Thread baptiste auguie
Hi, The following read might be useful, http://romainfrancois.blog.free.fr/index.php?post/2010/04/03/embed-images-in-Rd-documents baptiste On 29 March 2011 22:33, Etienne Stockhausen wrote: > Hey R-user, > > > > I’ve searched the archives about the following questions and didn’t find > anythin

Re: [R] save ordinary numerical calculations as pdf

2011-03-30 Thread baptiste auguie
Hi, If you want grid graphics: For data.frames and matrices, gridExtra has a grid.table() function. For strings (paragraph), Rgraphics has a function too, whose name i forget. It could be possible to combine the two and define a method to display lists as well. HTH, baptiste On 30 March 2011

Re: [R] Using graphics straight from R into published articles

2011-03-30 Thread baptiste auguie
Hi, For most purposes, I find that R graphics get 95% of the work done towards final publication. A couple of personal comments, - lattice, ggplot2, RColorBrewer, evidently. ggplot2, in particular, makes really good aesthetic decisions by default. - whilst R devices are really good, I find there

Re: [R] How to define new operator in R?

2011-03-30 Thread baptiste auguie
Hi, Also, try this and rm() it immediately, `+` <- function(x, y) x - y 1+1 rm(`+`) 1+1 baptiste On 31 March 2011 05:04, Chuanlong Du wrote: > Hello, everyone! > > Does anyone know how make some symbols have special means in R? For example, > we know that "+" in R means the sum of the two ope

Re: [R] Adding margin text to lattice graphics

2011-04-09 Thread baptiste auguie
Hi, You may want to read about ?viewport in the grid package. They allow you to position graphical elements wherever you want on a page, such as lattice plots and text (grid.text). For a high-level interface, you could try the following, library(gridExtra) library(lattice) p1 = xyplot(1~1) p2 =

Re: [R] Adding margin text to lattice graphics

2011-04-10 Thread baptiste auguie
l the question, whatever it was. Best, baptiste On 11 April 2011 09:54, Mark Leeds wrote: > hi  baptiste: thanks for that but how do I get mpg ? I got an error that R > couldn't find it. thanks again. > > > On Sat, Apr 9, 2011 at 9:45 PM, baptiste auguie > wrote: >>

Re: [R] bind mean to a df

2011-04-11 Thread baptiste auguie
Hi, You could try, library(plyr) ddply(data, .(name), transform, mean=mean(sale)) ddply(data, .(name), summarize, mean=mean(sale)) HTH, baptiste On 12 April 2011 15:46, Geoffrey Smith wrote: > Hello, I would like to take the mean of a column from a data frame and then > bind the mean back to

Re: [R] Assign with Paste Problem

2011-04-12 Thread baptiste auguie
Hi, You probably need ?get, though you might want to read this first, library(fortunes) fortune(236) HtH, baptiste On 13 April 2011 13:04, Sparks, John James wrote: > Dear R Helpers, > > I am trying to change the name of an object using the assign function. > When I use paste on the new obje

Re: [R] multiple lines on multiple plots

2011-04-12 Thread baptiste auguie
Hi, ggplot2 automatically adjusts its axes when new data are added to plots; however you wouldn't get an automatic legend if you constructed plots that way. HTH, baptiste On 13 April 2011 17:06, James Annan wrote: > Thanks for all the replies. Yes, I agree that calculating all the data first >

Re: [R] R plots pdf() does not allow spotcolors?

2011-04-13 Thread baptiste auguie
Hi, I may be wrong, but I have the impression that tikz (a LaTeX drawing package) can handle spot colors (that's what Google seemed to tell me [*]). If this is the case you could output R graphics using the tikzDevice package, post-process the output (readable, plain text file), and eventually hav

Re: [R] FW: [r] how to enclose two xyplot

2011-04-13 Thread baptiste auguie
Hi, Have you tried ?c.trellis in the latticeExtra package? HTH, baptiste On 13 April 2011 23:36, Francesco Nutini 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 sh

Re: [R] Line plots in base graphics

2011-04-13 Thread baptiste auguie
On 14 April 2011 07:51, Hadley Wickham wrote: > Am I missing something obvious on how to draw multi-line plots in base > graphics? > > In ggplot2, I can do: It appears you've been infected with what I like to call "the Dijkstra syndrome" [*], quoting "The tools we use have a profound (and devio

[R] modify particular factor levels

2011-04-14 Thread baptiste auguie
Dear list, I wish to modify programmatically only a few factor levels, according to a named list. I came up with this function, modify.levels <- function(f, modify=list()){ ## levels that will not be changed names.old.levels <- setdiff(levels(f), unlist(modify)) ## as a named list old.le

Re: [R] Plotting an Underbrace in R

2011-04-15 Thread baptiste auguie
Hi, Through pgfSweave you can use the tikz device, which is the one that can interpret Latex code (package tikzDevice). I would start with a minimal self-contained plot with this function. see ?tikz for examples. HTH, baptiste On 15 April 2011 20:03, Michael McAssey wrote: > Ben, > > This e

Re: [R] Deleting the last value of a vector

2011-04-17 Thread baptiste auguie
Hi, Try this, snip = function(x, n=1) { rand = sample(1:3, 1) print(paste("using algorithm #", rand)) switch(rand, '1' = head(x, length(x) - n), '2' = x[ seq(1, length(x) - n) ], '3' = x[ - seq(length(x), by=-1, length=n) ]) } snip(1:5) HTH, but please

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-18 Thread baptiste auguie
Hi, Does this help? library(gridExtra) my.title = function(expressions) { grid.table(expressions, parse=TRUE, theme=theme.list(gpar.corefill = gpar(fill = NA, col = NA), core.just = "left")) } e = expression(alpha,"text", italic(italic), hat(beta), integral(f(x

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-18 Thread baptiste auguie
mistake. For this code to work you'll need a more recent version of gridExtra than the one on CRAN. You can get it here: http://code.google.com/p/gridextra/ baptiste > Cheers, > > Marius > > On 2011-04-19, at 24:03 , baptiste auguie wrote: > >> Hi, >> >>

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread baptiste auguie
      ) > } > xyplot(1~1, panel=function(...) info(0.1, 0.5) ) > > > > On 2011-04-19, at 21:39 , David Winsemius wrote: > >> >> On Apr 19, 2011, at 3:26 PM, baptiste auguie wrote: >> >>> I'm hoping to release a new version on CRAN soon; the broken s

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread baptiste auguie
Hi, You may want to wait advice from someone who actually understands (the labyrinth that is) lattice's help for splom, but the following might be a start. I didn't understand what values you actually wanted displayed in the lower triangle panels, so I made up some random ones in a 3x3 matrix of 3

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-20 Thread baptiste auguie
ic(a)==phantom('')", round(pi,4), "italic(b)==phantom()", round(pi,6)), ncol=2, byrow=T) grid.table(d, parse=T,theme=theme.list( gpar.corefill=gpar(fill=NA, col=NA), core.just="left", padding.h = unit(0, "mm") )) HTH,

Re: [R] grid.table + splom: how to nicely align panel entries

2011-04-20 Thread baptiste auguie
On 20 April 2011 21:16, Marius Hofert wrote: > Dear expeRts, > > is there a way to get the entries in each panel correctly aligned according > to the > equality signs? > > Here is the "wish-list": > (1) the equality signs in each panel should be vertically aligned You can put the equal signs in

Re: [R] grid.table + splom: how to nicely align panel entries

2011-04-20 Thread baptiste auguie
ies per panel > f <- function(i,j) (i+j)*10 # dummy function > eq <- "phantom()==phantom()" > for(i in 1:d){ >    for(j in 1:d){ >        numbers <- align.digits(c(round(pi,4), round(pi, 6), f(i,j))) >        arr[i,j,] <- c("alpha", eq, numbers[1], &g

Re: [R] grid.table + splom: how to nicely align panel entries

2011-04-20 Thread baptiste auguie
uot;,"val")) # array containing the table entries per panel > f <- function(i,j) (i+j)*10 # dummy function > eq <- "phantom()==phantom()" > for(i in 1:d){ >    for(j in 1:d){ >        numbers <- align.digits(c(round(pi,4), round(pi, 6), f(i,j))) >        arr[i,j,] &l

Re: [R] 3D Bar Graphs in ggplot2?

2011-08-03 Thread baptiste auguie
A barplot rendered with povray, http://zoonek2.free.fr/UNIX/48_R/03.html#10 At the other end of the spectrum, library(txtplot) x <- factor(c("orange", "orange", "red", "green", "green", "red", "yellow", "purple", "purple", "orange")) o <- capture.output(txtbarchart(x)) library(

Re: [R] Can you send "side effect" text into a variable?

2011-08-15 Thread baptiste auguie
Hi, Try this, ?capture.output as in, capture.output(cat("this is it")) HTH, baptiste PS: Here's another example for fun, # library(textplot) capture.output(txtplot(1:10)) library(gplots) textplot(capture.output(txtplot(1:10))) library(grid) grid.cap() # not sure how to get back to the orig

Re: [R] Query for semi-transparency support

2011-08-15 Thread baptiste auguie
Here's a warning, but it sounds like it's at a deep (C, presumably) level, xfig() grid::grid.rect(gp=gpar(fill="red", alpha=0.5)) Warning message: In grid.Call.graphics("L_rect", x$x, x$y, x$width, x$height, resolveHJust(x$just, : semi-transparency is not supported on this device: reported only

Re: [R] Writing non-graphic (text) output to PDF

2011-08-19 Thread baptiste auguie
Hi, Try this, library(gridExtra) example(grid.table) or addtable2plot() in plotrix, or textplot() in gplots, or Hmisc using latex, or Sweave, ... HTH, baptiste PS: please read the posting guide On 20 August 2011 05:14, Ed Heaton wrote: > Hi, friends. > > I keep coming to you because I'm so

Re: [R] Scatter Plot Command Syntax Using Data.Frame Source

2011-08-31 Thread baptiste auguie
Hi, Below are a couple of options using a standard dataset, str(iris) ## using base graphics d <- split(iris, iris$Species) str(d) # list of 3 data.frames par(mfrow=n2mfrow(length(d))) # split the device in 3 plotting regions b.quiet <- lapply(names(d), function(x) { # loop over the list names

Re: [R] ggplot2 to create a "square" plot

2011-09-01 Thread baptiste auguie
Hi, Are you after this? last_plot() + opts(aspect.ratio=1) Also, see https://github.com/hadley/ggplot2/wiki/Themes for some settings re: plot margins. HTH, baptiste On 1 September 2011 05:18, Alaios wrote: > Dear all, > I am using ggplot with geom_tile to print as an image a matrix  I have.

Re: [R] Coloring Dirichlet Tiles

2011-09-04 Thread baptiste auguie
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

Re: [R] Add png image outside plot borders

2011-09-18 Thread baptiste auguie
Hi, if your logo is in vector format you should probably try the grImport package; see its vignette for examples, also below, library(grImport) ## http://creativecommons.org/about/downloads/ PostScriptTrace("cc.logo.eps") cc <- readPicture("cc.logo.eps.xml") logo <- pictureGrob(cc[16:18], x=un

Re: [R] package grid: mirror grob objects along an axis

2012-06-03 Thread baptiste auguie
Hi, Another option that you might want to try is the tikzDevice package; tikz has functions to flip and rotate objects and could it from R with tikzAnnotate / tikzAnnotateGrob. Of course these objects would not really be grobs but tikz code, though for text the end result would probably be the sam

Re: [R] Regions of significance plots with ggplot2

2012-06-05 Thread baptiste auguie
Hi, On 6 June 2012 08:58, Paul Murrell wrote: > Hi > > Here's one way to approach it ... > > ggplot(data.frame(x=1:10, y=1:10)) + >  geom_polygon(aes(x=xx, y=yy), fill="grey70", >               data=data.frame(xx=c(0, 0, 4, 4), yy=c(0, 11, 11, 0))) + >  geom_point(aes(x=x, y=y)) > > ... (supply a

Re: [R] Rotating characters in text

2012-06-12 Thread baptiste auguie
Try this, rotate = function(x) paste(strsplit(x,"")[[1]],collapse="\n") t <- "this is a text" plot.new() text(1/2,1/2,t) par(lheight=0.8) text(1/2,1/2,rotate(t)) HTH, b. On 13 June 2012 01:49, Stuart Rosen wrote: > For labelling a plot, I am trying to rotate a character string using text() >

Re: [R] Format text with outline?

2012-06-19 Thread baptiste auguie
Have a look at this: http://stackoverflow.com/questions/7734535/control-font-thickness-without-changing-font-size and http://stackoverflow.com/questions/10686054/outlined-text-with-ggplot2 which refers to a base graphics version. HTH, b. On 20 June 2012 07:58, MacQueen, Don wrote: > I'm usin

Re: [R] Creating interactive 3D graphs for embedding in pdf not possible in R?

2012-06-22 Thread baptiste auguie
Hi, Try this post: http://r.789695.n4.nabble.com/Exporting-an-rgl-graph-tp1872712p1905113.html HTH, b. On 22 June 2012 19:26, Rainer M Krug wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi > > Just to be sure: I couldn't find a way of creating an interactive 3d graph > which ca

Re: [R] Loop for multiple plots in figure

2012-06-25 Thread baptiste auguie
Hi, Here's one approach: plot_one <- function(d){ with(d, plot(Xvar, Yvar, t="n")) # set limits with(d[d$param1 == 0,], lines(Xvar, Yvar, lty=1)) # first line with(d[d$param1 == 1,], lines(Xvar, Yvar, lty=2)) # second line } par(mfrow=c(2,2)) plyr::d_ply(data, "Subject", plot_one) HTH,

Re: [R] Loop for multiple plots in figure

2012-06-26 Thread baptiste auguie
Try this alternative solution using only base functions: # split the data into 4 data.frames l <- split(data, data$Subject) names(l) # set up the graph parameters par(mfrow=n2mfrow(length(l)), mar=c(4,4,1,1), mgp = c(2, 1, 0)) # good old for loop over the subject names for( n in names(l)){ d <-

Re: [R] Loop for multiple plots in figure

2012-06-27 Thread baptiste auguie
You can use main = unique(d$Subject) to solve this problem. HTH, b. On 27 June 2012 08:49, Marcel Curlin wrote: > Well at this point I have what I need (rough plot for data exploration) but > the simplicity of the first approach is quite elegant and it has become a > learning project. I have su

Re: [R] plot background - excel gradient style background ?

2012-06-29 Thread baptiste auguie
Looking at these, and in retrospect, if I were writing a manuscript of the pre-digital age, I would definitely add a burning mark as a finishing touch to complete the work. Perhaps waving the parchment above a burning candle. With modern digital support, you can fake a similar result using e.g. gr

Re: [R] gridExtra with cairodevie and ggplots

2011-06-14 Thread baptiste auguie
Hi, You can draw arrangeGrob in a rotated viewport, library(gridExtra) library(ggplot2) ps = replicate(4, qplot(rnorm(10), rnorm(10)), simplify=F) g = gTree(children=gList(do.call(arrangeGrob, ps)), vp=viewport(angle=90)) grid.draw(g) though you get some warnings about clipping for some reason.

Re: [R] Placing Text on ggplot2 graphics vs. xyplot

2011-06-16 Thread baptiste auguie
Hi, As far as I know secondary y-axis and multiple pages are not possible in ggplot2 (there are workarounds for the latter in the ggplot2 list archives). For the subtitle, you could implement it with grid.text and grid viewports, library(gridExtra) library(ggplot2) grid.arrange( qplot(1,1), sub

Re: [R] Creating a Polar Plot with expanding points as radius increases

2011-06-27 Thread baptiste auguie
Try this, library(ggplot2) d <- data.frame(theta = runif(10, 0, 360), r = runif(10, 0, 3)) ggplot(d, aes(x=theta, y=r, size=r)) + coord_polar(start=0)+ geom_point() + scale_x_continuous(breaks=seq(0, 360, by=30), expand=c(0,0), lim=c(0, 360))+ scale_area() HTH, baptiste On 28 June 2011

Re: [R] plot a vertical column of colored rectangles

2011-07-16 Thread baptiste auguie
Hi, You could try grid.colorstrip() from the gridExtra package, grid.colorstrip(ifelse(dat, "blue", "red")) or grid.raster(), which should be more efficient, grid.raster(matrix(ifelse(dat, "blue", "red")), interp=FALSE, width=unit(1,"npc"), height=unit(1,"npc")) HTH, baptiste On 15 July 201

[R] grImport symbols

2011-07-30 Thread baptiste auguie
Dear list, I have two questions regarding grid.symbols() in the grImport package. This package allows you to import a vector graphic in R, and grid.symbols() can be used to plot the resulting glyph at arbitrary locations in a grid viewport. I have tried the code in the grImport vignette, which is

Re: [R] Styling gridExtra's title and left labels

2012-08-07 Thread baptiste auguie
Hi, You can use a grob instead of a text string, e.g main = textGrob("Title goes here", gp=gpar(fontsize=24)) HTH, b. On 7 August 2012 03:49, Alastair wrote: > Hi, > > I'm using the gridExtra package to combine some graphs like in the > arrangeGrob example. Each of the graphs has a title but

Re: [R] Overlay Histogram

2012-08-08 Thread baptiste auguie
Hi, On 9 August 2012 08:40, li li wrote: > Dear all, >I have a few extra questions regarding this. Below is my code. > My questions are: > (1), How can I remove the labels, tick marks and numbers, and the word > "density" for the histgrams. > (2) On the top right corner, there is a empty g

Re: [R] regular expression for selection

2011-11-14 Thread baptiste auguie
Hi, Try grepl instead of sub, mena[grepl("m5.", mena)] HTH, baptiste On 14 November 2011 21:45, Petr PIKAL wrote: > Dear all > > I am again (as usual) lost in regular expression use for selection. Here > are my data: > >> dput(mena) > c("138516_10g_50ml_50c_250utes1_m53.00-_s1.imp", > "138516

Re: [R] grid.arrange, grid.layout - legend, global y axis title

2011-11-15 Thread baptiste auguie
Hi, Please don't cross post. It seems that ggplotGrob has been replaced by new functions. You can define it as ggplotGrob <- function(x) ggplot2:::gtable_gTree(ggplot2:::ggplot_gtable(x)) and it seems to work as before with grid.arrange(). HTH, baptiste On Wed, Nov 16, 2011 at 3:26 AM, Joha

Re: [R] How to fill irregular polygons with patterns?

2011-11-18 Thread baptiste auguie
Hi, Two possible routes I can suggest: 1- export the plot in svg format, which supports natively the use of filling patterns, e.g. http://www.w3.org/TR/SVG/images/pservers/pattern01.svg It's possible that the gridSVG package could help you automate the process of "grid.garnish()-ing" the grobs;

Re: [R] rendering or raytracing?

2011-12-19 Thread baptiste auguie
Hi, package planar is concerned with the full electromagnetic problem at planar interfaces, which is not very useful for raytracing. The cda package includes a small demo interfacing either rgl or povray (via system call) to visualize 3D clusters of metallic particles. A more general interface to

Re: [R] black and white in qplot? layout 4 graphs in one screen

2011-12-23 Thread baptiste auguie
Hi, On 22 December 2011 09:16, rachaelohde wrote: > Hello, > > I am trying to plot means and standard errors conditioned by a factor, using > qplot.  I am successful at getting the bar graph I want with a error bar, > however I have tried many things and cannot get the bars to change colors. > Cu

Re: [R] How to turn a LaTeX Sweave file (Rnw) into .HTML/.odf/.docx? (under windows)

2011-09-22 Thread baptiste auguie
Have you tried asciidoc (ascii package)? It seems like a good fit for your needs. baptiste On 23 September 2011 11:09, Tal Galili wrote: > Hello dear R help members, > I have found several references on how to do this, my question is if anyone > is actually using them - and if there are some s

Re: [R] new standardised variable based on group membership

2011-10-03 Thread baptiste auguie
More concisely, ddply(Orange, .(Tree), transform, scaled = scale(age)) HTH, baptiste On 4 October 2011 11:24, wrote: > That works a treat Thierry, thanks! I wasn't aware of the plyr package but I > like what it does- I'll put it to use work in the future. > > Regards > > John > > -Origin

Re: [R] adding a dummy variable...

2011-10-04 Thread baptiste auguie
Hi, Using ddply, ddply(df, .(ID), mutate, nrows=length(rel.head), test = nrows==2 & all(rel.head %in% c(1,3))) HTH, baptiste On 5 October 2011 06:02, Dennis Murphy wrote: > Hi: > > Here's another way to do it with the plyr package, also not terribly > elegant. It assumes that rel.head is a f

Re: [R] white on black theme for ggplot2

2011-10-05 Thread baptiste auguie
Hi, there are a couple of themes proposed in the wiki, one being white on black, https://github.com/hadley/ggplot2/wiki/Themes HTH, baptiste On 6 October 2011 04:05, Eugene Kanshin wrote: > Hello, > I'm trying to produce some plots in ggplot2 to use them on > the dark-blue gradient background

Re: [R] Display a contingency table on the X11 device

2011-10-05 Thread baptiste auguie
On 6 October 2011 09:23, Dennis Murphy wrote: > Hi: > > One option is the gridExtra package - run the example associated with > the tableGrob() function. Another is the addtable2plot() function in > the plotrix package. I'm pretty sure there's at least one other > package that can do this; I thoug

Re: [R] using do.call to call a list of functions

2011-10-14 Thread baptiste auguie
package plyr makes it easier, plyr::each(function.list)(pi) HTH, baptiste On 15 October 2011 11:55, Richard M. Heiberger wrote: >> function.list=c(sin, cos, function(x) tan(x)) >> for (f in function.list) print(f(pi)) > [1] 1.224606e-16 > [1] -1 > [1] -1.224606e-16 >> > > On Fri, Oct 14, 2011

Re: [R] right justify right-axis tick values in lattice

2011-10-16 Thread baptiste auguie
Hi, You could also pad the text labels with phantom 0s, ghostrighter <- function(x, ...){ n <- sapply(x, nchar) nmax <- max(n) padaone <- function(ii){ si <- paste(rep("0", length= nmax - n[ii]), collapse="") as.expression(bquote(phantom(.(si)) * .(x[ii]) )) } sapply(seq_along(

Re: [R] converting string fractions to numerics

2011-10-18 Thread baptiste auguie
Hi, I believe you want eval(parse(text="pi/2")) a word of warning exemplified in eval(parse(text="library(fortunes) ; fortune(106)")) HTH, baptiste On 19 October 2011 19:30, Erin Hodgess wrote: > Dear R People: > > Suppose I have the following: > > "pi/2" > > and I would like it to be 1.5

Re: [R] Simple color strip

2011-10-19 Thread baptiste auguie
Hi, Perhaps the easiest way is with grid.raster, library(grid) pdf("colorstrip.pdf", height=1, width=10) grid.raster( t(myCols), width=unit(1,"npc"), height=unit(1,"npc"), interpolate=FALSE) dev.off() HTH, baptiste On 20 October 2011 03:32, Brian Smith wrote: > Hi, > > I was trying to get an

Re: [R] "Plotting" text?

2011-10-21 Thread baptiste auguie
Try this, library(grid) grid.newpage() grid.text("text") HTH, baptiste On 22 October 2011 13:26, wrote: > > I noticed that the text() command adds text to a plot. Is there a way to > either make the plot blank or add text to a "blank sheet". I would like > to "plot" a page that contains just

Re: [R] palettes for the color-blind

2011-11-02 Thread baptiste auguie
Hi, Try the dichromat package (also dichromat_pal in the scales package). HTH, baptiste On 3 November 2011 10:26, Max Kuhn wrote: > Everyone, > > I'm working with scatter plots with different colored symbols (via > lattice). I'm currently using these colors for points and lines: > > col1 <- c(

Re: [R] adjusting levelplot color scale to data

2011-11-06 Thread baptiste auguie
Hi, Try specifying explicit break points together with their corresponding colors using at and col.regions, levelplot(m, at= unique(c(seq(-2, 0, length=100), seq(0, 10, length=100))), col.regions = colorRampPalette(c("blue", "white", "red"))(1e3)) HTH, baptiste On 7 November 2011 16:08, Lanna

[R] performance of adaptIntegrate vs. integrate

2011-11-10 Thread baptiste auguie
Dear list, [cross-posting from Stack Overflow where this question has remained unanswered for two weeks] I'd like to perform a numerical integration in one dimension, I = int_a^b f(x) dx where the integrand f: x in IR -> f(x) in IR^p is vector-valued. integrate() only allows scalar integrands,

Re: [R] performance of adaptIntegrate vs. integrate

2011-11-11 Thread baptiste auguie
Dear Ravi, Thank you for your answer. The integrand I proposed was a dummy example for demonstration purposes. I experienced a similar slowdown in a real problem, where knowing in advance the shape of the integrand would not be so easy. Your advice is sound; I would have to study the underlying

Re: [R] performance of adaptIntegrate vs. integrate

2011-11-11 Thread baptiste auguie
Dear Hans, [see inline below] On 11 November 2011 22:44, Hans W Borchers wrote: > baptiste auguie googlemail.com> writes: > >> >> Dear list, >> >> [cross-posting from Stack Overflow where this question has remained >> unanswered for two weeks] >> &

Re: [R] Computing line= for mtext

2012-03-02 Thread baptiste auguie
Hi, If you're going to use different text sizes and convert between units, it might be easier to do the calculations with grid. par(mar=c(1,1,1,5)) plot(1:10) labels = c(1, 2, 10, 123, 3.141592653589, 1.2, 2) sizes = c(1, 1, 2, 1, 0.4, 1, 3) # cex of individual labels ## pure base graphics max_w

Re: [R] Two dimensional integration

2012-03-12 Thread baptiste auguie
Hi, Try the cubature package, and maybe play with the tolerance. HTH, b. On 13 March 2012 18:39, Niroshan wrote: > Dear R Members, > > I want to know a fast R function to do multidimensional integration.  I used > the function 'cuhre' in R2cuba library. But it takes painful time to get the > a

Re: [R] how to dev.off() all devices

2012-03-15 Thread baptiste auguie
Hi, Try this, replicate(sample(10,1), dev.new()) graphics.off() HTH, baptiste On 15 March 2012 20:36, Alaios wrote: > Dear all, > I would like at the beginning of my code to turn off all the remaining open > devices. > > How can I do that by using dev.off()? > > I would like to thank you in a

Re: [R] Adding text for written comments to bottom of graphs

2012-03-30 Thread baptiste auguie
Hi, I would do the following, library(ggplot2) require(reshape) TestData <- structure(list(profile_key = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3), line = c(1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1), instance = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2), drug = structure(c(

Re: [R] Adding text for written comments to bottom of graphs

2012-03-31 Thread baptiste auguie
Hi, On 1 April 2012 03:41, Paul Miller wrote: > Hello Baptiste, > > What you've done is very interesting. Went through and tried to understand > all the steps. Reminded me of studying languages in years gone by. Always > found it easier to read and understand a sentence than to construct a > s

[R] scan() vs readChar() speed

2012-04-01 Thread baptiste auguie
Dear list, I am trying to find a fast solution to read moderately large (1 -- 10 million entries) text files containing only tab-delimited numeric values. My test file is the following, nr <- 1000 nc <- 5000 m <- matrix(round(rnorm(nr*nc),3),nr=nr) write.table(m, file = "a.txt", append=FALSE,

Re: [R] scan() vs readChar() speed

2012-04-01 Thread baptiste auguie
might be causing this? Thanks, baptiste On 2 April 2012 11:04, Duncan Murdoch wrote: > On 12-04-01 2:58 AM, baptiste auguie wrote: >> >> Dear list, >> >> I am trying to find a fast solution to read moderately large (1 -- 10 >> million entries) text files cont

Re: [R] ggExtra package installation fails

2012-01-15 Thread baptiste auguie
ggExtra was not compatible with the recent changes in ggplot2 and had become partially redundant, so I removed it. grid.arrange and arrangeGrob in gridExtra won't help with the alignment of axes. align.plots, which I can always send you offlist if you want, extracted the size of axes and legends f

<    1   2   3   4   5   6   7   8   >