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 heat...@comcast.net wrote: Hi, friends. I keep coming to

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 inspired2apa...@gmail.com wrote: So, I've been confused by this for a while.  

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,

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 wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ivo welch

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 einohr2...@web.de wrote: Hey R-user, I’ve searched the archives about the following questions and didn’t

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

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

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 dcl...@iastate.edu 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

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
the question, whatever it was. Best, baptiste On 11 April 2011 09:54, Mark Leeds marklee...@gmail.com 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 baptiste.aug...@googlemail.com

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 g...@asu.edu wrote: Hello, I would like to take the mean of a column from a data frame and then bind the

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 jspa...@uic.edu wrote: Dear R Helpers, I am trying to change the name of an object using the assign function. When I use paste on

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 jdan...@jamstec.go.jp wrote: Thanks for all the replies. Yes, I agree that calculating

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

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 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.

Re: [R] Line plots in base graphics

2011-04-13 Thread baptiste auguie
On 14 April 2011 07:51, Hadley Wickham had...@rice.edu 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

[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

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 mpmcas...@gmail.com

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),

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

2011-04-18 Thread baptiste auguie
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, Does this help? library(gridExtra) my.title = function(expressions) {  grid.table

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

2011-04-19 Thread baptiste auguie
=gpar(fill=NA, col=NA), # make bg transparent               core.just=left) # justification of labels               ) } 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

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

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

2011-04-20 Thread baptiste auguie
)), 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, baptiste On 2011-04-20, at 01:33 , baptiste auguie wrote: Hi, You may want to wait advice from someone who

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 m_hof...@web.de 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

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

2011-04-20 Thread baptiste auguie
)))        arr[i,j,] - c(alpha, eq, numbers[1],                       italic(bbb), eq, numbers[2],                       gamma, eq, numbers[3])    } } ## plot splom2(x, arr, nr=3) On 2011-04-20, at 11:56 , baptiste auguie wrote: On 20 April 2011 21:16, Marius Hofert m_hof...@web.de wrote

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

2011-04-20 Thread baptiste auguie
])    } } ## plot splom2(x, arr, nr=3) On 2011-04-20, at 22:38 , baptiste auguie wrote: Try this, align.digits = function(l) { sp - strsplit(as.character(l), \\.) chars - sapply(sp, function(x) nchar(x)[1]) n = max(chars) - chars l0 = sapply(n, function(x) paste(rep(0, x), collapse=)) labels

Re: [R] multiple mosaic plots layout

2011-05-01 Thread baptiste auguie
Unfortunately, it seems that vcd doesn't return grobs but draws directly to the device, which prevents a concise solution. You could try the following, library(gridExtra) library(vcd) data(Titanic) p = grid.grabExpr(mosaic(Titanic)) grid.arrange(p, p, p, ncol=2) Or, more versatile but also more

Re: [R] adaptIntegrate - how to pass additional parameters to the integrand

2011-05-03 Thread baptiste auguie
Hi, The package maintainer is aware of this feature request. In the meantime, I've used Currying, require(cubature) f - function(x, a) cos(2*pi*x*a) # a simple test function adaptIntegrate(roxygen::Curry(f, a=0.2), lower=0, upper=2) HTH, baptiste On 4 May 2011 05:57, Ravi Varadhan

Re: [R] Options for print()

2011-05-05 Thread baptiste auguie
Hi, Try this, cat(format(The TITLE, width=80, justify=centre)) HTH, baptiste On 5 May 2011 19:28, Dan Abner dan.abne...@gmail.com wrote: Hello everyone, I have a few questions about the print() fn: 1) I have the following code that does not center the character string: print(The

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 ala...@yahoo.com wrote: Dear all, I am using ggplot with geom_tile to print as an image a

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,

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=unit(1,

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 tal.gal...@gmail.com 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

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, john.morrongie...@csiro.au 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

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 djmu...@gmail.com wrote: Hi: Here's another way to do it with the plyr package, also not terribly elegant. It assumes that

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 kanshin...@gmail.com wrote: Hello, I'm trying to produce some plots in ggplot2 to use them on the dark-blue

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

2011-10-05 Thread baptiste auguie
On 6 October 2011 09:23, Dennis Murphy djmu...@gmail.com 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

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 r...@temple.edu 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,

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(x),

Re: [R] converting string fractions to numerics

2011-10-19 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 erinm.hodg...@gmail.com wrote: Dear R People: Suppose I have the following: pi/2 and I would like

Re: [R] parse .ps files with R?

2012-02-18 Thread baptiste auguie
Hi, the grImport package provides some tools for this. HTH, b. On 19 February 2012 16:06, Nick Matzke mat...@berkeley.edu wrote: Hi, Is there a way to parse a postscript (*.ps) file with R (or perhaps with some other command-line utility)? E.g., I have a map in postscript format with

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

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 wnnpe...@ucalgary.ca 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

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 ala...@yahoo.com 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

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 =

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 pjmiller...@yahoo.com 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

[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 murdoch.dun...@gmail.com 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 containing only tab-delimited

Re: [R] tableGrob and properties of a cell

2010-12-07 Thread baptiste auguie
Hi, Embarrassingly enough, it was quite straight-forward in the first versions of grid.table(). You might want to try with version r11 for example, source(http://gridextra.googlecode.com/svn-history/r11/trunk/R/tableGrob.r;) library(grid) tc = textConnection( carat VeryLongWordIndeed

Re: [R] ggplot - line_range help, second tier axis label

2010-12-08 Thread baptiste auguie
Hi, The easiest way to get the wide curly braces in your plot might be the tikzDevice package. In its vignette you'll find an example of placing an arbitrary tikz element in a plot, featuring a curly bracket. Sadly, the internal coordinate system used by ggplot2 might make the positioning a

Re: [R] Legendre polynomials

2010-12-08 Thread baptiste auguie
Hi, Try the package orthopolynom on CRAN. HTH, baptiste On 8 December 2010 12:51, Alaios ala...@yahoo.com wrote: Hello everyone, I would like to find out if there are already implemented function for legendre polynomials. I tried google but returns nothing. How do you suggest me to

Re: [R] lines and points without margin

2010-12-14 Thread baptiste auguie
Hi, Try the following, plot(1:10,rnorm(10),t=o) ## fill the points in white plot(1:10,rnorm(10),t=o,pch=21,bg=white) You could also try this with Grid graphics, library(gridExtra) # like type=o grid.barbed(space=0) # like type=b grid.barbed(space=1) # like the example above, but without

Re: [R] test whether all elements of a vector are identical

2010-12-16 Thread baptiste auguie
Hi, The fastest way seems to be, all(x[1] == x) HTH, baptiste On 16 December 2010 15:17, Jannis bt_jan...@yahoo.de wrote: Dear list, this might be an easy one, but I could figure out a solution (or how to google the right term). Is there any way to test whether all elements of a

Re: [R] another superscript problem

2010-12-28 Thread baptiste auguie
Hi, this seems to work, plot.new() legend(topleft, legend=as.expression(c(bquote(.(txt) == .(obv)*degree), Von Mises distribution))) HTH, baptiste On 28 December 2010 20:17, Tyler Dean Rudolph tylerdeanrudo...@gmail.com wrote: legend(topleft, legend=c(bquote(.(txt) == .(obv)*degree), Von

Re: [R] forming function arguments from strings

2011-01-01 Thread baptiste auguie
See aes_string(), perhaps. baptiste On 1 January 2011 18:56, Mark Sharp msh...@sfbr.org wrote: I am wanting to change arguments to a function dynamically. For example, in making a call to qplot, I want to dynamically define all of the arguments so that I can create the plot dependent on

Re: [R] Creating a Matrix from a vector with some conditions

2011-01-09 Thread baptiste auguie
Hi, embed() seemed well-suited, but I couldn't figure out an elegant way to use it embed(c(A,A), 4)[1:4, 4:1] HTH, baptiste On 6 January 2011 22:34, ADias diasan...@gmail.com wrote: Hi Suppose we have an object with strings: A-c(a,b,c,d) Now I do: B-matrix(A,4,4, byrow=F) and I

Re: [R] Changing a logical matrix into a numeric matrix

2011-01-10 Thread baptiste auguie
Hi, Try this, mode(m) - integer HTH, baptiste On 10 January 2011 10:17, emj83 stp08...@shef.ac.uk wrote: Hi, I would like to turn my TRUE/FALSE matrix into a 1/0 matrix (i.e. True=1 and False=0)      [,1]  [,2]  [,3] [1,]  TRUE FALSE FALSE [2,]  TRUE  TRUE FALSE [3,]  TRUE  TRUE  

Re: [R] Basic ggplot question

2011-01-10 Thread baptiste auguie
Hi, Try this, m = melt(dat, id=Date) head(m) qplot(Date, value, data=m, colour=variable, geom=line) ggplot(m) + facet_grid(variable~., scales=free_y) + geom_path(aes(Date, value)) HTH, baptiste On 10 January 2011 14:12, Santosh Srinivas santosh.srini...@gmail.com wrote: Hello R-Group,

Re: [R] Basic ggplot question

2011-01-10 Thread baptiste auguie
of layers, qplot(Date, Close, data=dat,geom=line) + geom_line(aes(Date, vol), colour=red) HTH, baptiste -Original Message- From: baptiste auguie [mailto:baptiste.aug...@googlemail.com] Sent: 10 January 2011 18:59 To: Santosh Srinivas Cc: r-help@r-project.org Subject: Re: [R] Basic

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 bsmith030...@gmail.com wrote: Hi, I was

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, rkevinbur...@charter.net 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

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 mxk...@gmail.com wrote: Everyone, I'm working with scatter plots with different colored symbols (via lattice). I'm currently using these colors for points and lines:

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 Jin

[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 hwborch...@googlemail.com wrote: baptiste auguie baptiste.auguie at googlemail.com writes: Dear list, [cross-posting from Stack Overflow where this question has remained unanswered for two weeks] I'd like

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 petr.pi...@precheza.cz wrote: Dear all I am again (as usual) lost in regular expression use for selection. Here are my data: dput(mena)

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,

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 cox.rach...@gmail.com 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

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

Re: [R] graph paper look

2012-01-18 Thread baptiste auguie
You could draw a grid with grid, using grid.grill, library(grid) pdf(grid.pdf, width=21/2.54,height=29.7/2.54) grid.grill(h = unit(seq(0, 297, by=1), mm), v = unit(seq(0, 210, by=1), mm), gp=gpar(col=grey,lwd=0.1)) grid.grill(h = unit(seq(0, 297, by=5), mm), v = unit(seq(0,

Re: [R] Executable expressions

2012-01-18 Thread baptiste auguie
One reason might be that you can easily fool the user into running unexpected/unreadable commands. Guess what this does: cmd - paste(c(letters[c(19L, 25L, 19L, 20L, 5L, 13L)], (' , letters[c(19L, 21L, 4L, 15L)], , letters[c(4L, 5L, 19L, 20L, 18L, 15L, 25L)], , letters[c(1L, 12L, 12L)], ')),

Re: [R] Gray levels

2012-01-25 Thread baptiste auguie
The scales package? gradient_n_pal(c(red,white,blue), c(0,0.5,1)) (seq(0,1,length=100)) HTH, baptiste On 26 January 2012 10:36, Jeffrey Joh johjeff...@hotmail.com wrote: The gray (level) function returns different shades of gray, where level is a vector of numbers ranging from 0 to 1.  0

Re: [R] logical subsetting, indexes and NAs

2012-01-28 Thread baptiste auguie
Hi, which(x 15) omits the NA (treated as false). HTH, b. On 29 January 2012 09:36, Federico Calboli f.calb...@imperial.ac.uk wrote: Dear All, just a quick example: x  = 1:25 x[12] = NA x  [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 y = x[x10] y  [1]  1

Re: [R] How I assign the result of a plot to a variable?

2012-01-29 Thread baptiste auguie
Try this, plot(1:10) img - grid::grid.cap() # grid.raster(img) stream - col2rgb(img) write.table(stream, file=dam.txt, row.names = FALSE, col.names = FALSE) (you'll have to restore the dimensions of the matrix once you've read the rgb values for each pixel) HTH, baptiste On 30

Re: [R] how do I exort a list of numbers into csv file?

2012-02-05 Thread baptiste auguie
Hi, If you don't mind having NAs for missing values, try the following, mylist = list(1:3, 4:7) library(plyr) write.csv(do.call(rbind.fill.matrix, lapply(mylist, matrix, nrow=1)), file=) HTH, b. On 6 February 2012 15:01, Michael comtech@gmail.com wrote: Hi all, I have a list of vector

Re: [R] 3D confidence ellipsoid with ellipse projections onto 2D plane

2012-02-08 Thread baptiste auguie
Hi, If you read French, you might find the following discussion interesting, http://www.forum.math.ulg.ac.be/viewthread.html?id=45765 It contains some good suggestions to project an ellipsoid onto a plane, which as I understand might be related to your question. HTH, b. On 8 February 2012

Re: [R] Version control (git, mercurial) for R packages

2012-02-08 Thread baptiste auguie
On 9 February 2012 13:02, David Winsemius dwinsem...@comcast.net wrote: On Feb 8, 2012, at 6:33 PM, Tom Roche wrote: Peter Langfelder Thu Feb 9 00:01:31 CET 2012 I'm exploring using a version control system +1! welcome to the new millenium :-) to keep better track of changes to the [R]

Re: [R] Version control (git, mercurial) for R packages

2012-02-09 Thread baptiste auguie
Once upon a time r-forge had the option to sync from an external svn repository, e.g. hosted on googlecode. I haven't seen it available for some time, sadly. I'm sure many users would appreciate if this feature came back with the new interface. Not sure if it could work with git as well, though.

Re: [R] Color cells of a matrix as in Excel

2012-02-14 Thread baptiste auguie
A minimum code to plot a coloured matrix with text labels could be the following: library(grid) library(scales) library(RColorBrewer) diverging_palette - function(d = NULL, centered = FALSE, midpoint = 0, colors = brewer.pal(7,PRGn)){ half - length(colors)/2

Re: [R] Defining a viewport scale in {Grid}

2012-02-16 Thread baptiste auguie
The default units of polygonGrob are npc, I think you want native instead. Try the following, library(grid) d = data.frame(x=rnorm(100, 10), y=rnorm(100, -100)) v = dataViewport(xData=d$x, yData=d$y) grid.points(d$x,d$y, default.units=native, vp=v) HTH, b. On 17 February 2012 02:47,

Re: [R] %in% operator - NOT IN

2011-05-08 Thread baptiste auguie
Hi, On 8 May 2011 21:18, Berwin A Turlach berwin.turl...@gmail.com wrote: G'day Dan, On Sun, 8 May 2011 05:06:27 -0400 Dan Abner dan.abne...@gmail.com wrote: Hello everyone, I am attempting to use the %in% operator with the ! to produce a NOT IN type of operation. Why does this not work?

Re: [R] identical function names from 2 packages

2011-05-20 Thread baptiste auguie
I imagine mind_read() easy to implement with Robin Hankin's emulator package -- under some weak assumptions about the user; mind_write(), however, seems more involved and might require investing in new hardware. Best, baptiste On 21 May 2011 12:04, Rolf Turner rolf.tur...@xtra.co.nz wrote: On

Re: [R] Group by multiple variables

2011-05-30 Thread baptiste auguie
Hi, There are probably much better ways, but try this transform(dat, group = as.numeric(factor(paste(A,B,C, sep= HTH, baptiste On 31 May 2011 09:47, Mendolia, Franco fmendo...@mcw.edu wrote: Hello, I would like to create a group variable that is based on the values of three

Re: [R] Value of 'pi'

2011-05-31 Thread baptiste auguie
I propose a Pi Haiku (PIQ), Pi is of certain value, In statistics, invaluable, yet Transcending numerics. Best, baptiste On 1 June 2011 11:55, Ravi Varadhan rvarad...@jhmi.edu wrote: Nice to know that the `pi' can be sliced in so many different ways! There are exactly 3.154 x e08 seconds in

Re: [R] cbind 3 or more matrices

2011-06-04 Thread baptiste auguie
A, B, C should have the same number of rows. mlist = replicate(3, matrix(rnorm(6), 2), simplify=FALSE) names(mlist) = LETTERS[seq_along(mlist)] with(mlist, cbind(A,B,C)) or, do.call(cbind, mlist) HTH, baptiste On 5 June 2011 11:14, Jim Silverton jim.silver...@gmail.com wrote: How can I

Re: [R] Heatmap in R and/or ggplot2

2011-06-13 Thread baptiste auguie
Hi, Try this ggplot(df, aes(x,y)) + geom_tile(aes(fill=height), colour=white) + scale_fill_gradientn(colours = c(red, gold, green)) + geom_text(aes(lab=height)) HTH, baptiste On 14 June 2011 07:12, idris idris.r...@gmail.com wrote: I have a dataframe df with columns x, y, and height. I want

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] sweave tables as images?

2012-05-25 Thread baptiste auguie
you can open a device that has the exact dimensions of the table, g = tableGrob(head(iris, 4)) png(test.png, width=convertWidth(grobWidth(g), in, value=TRUE), height=convertHeight(grobHeight(g), in, value=TRUE),units=in, res=150) grid.draw(g) dev.off() Doing this with knitr might be

Re: [R] sweave tables as images?

2012-05-25 Thread baptiste auguie
2012 09:43, Alexander Shenkin ashen...@ufl.edu wrote: this works - thanks baptiste!  i'm working in Sweave right now - perhaps it will be tough in knitr as you mention. On 5/25/2012 4:31 PM, baptiste auguie wrote: you can open a device that has the exact dimensions of the table, g = tableGrob

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

Re: [R] Regions of significance plots with ggplot2

2012-06-05 Thread baptiste auguie
Hi, On 6 June 2012 08:58, Paul Murrell p.murr...@auckland.ac.nz 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))

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 s.ro...@ucl.ac.uk wrote: For labelling a plot, I am trying to rotate a character string

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

<    2   3   4   5   6   7   8   >