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-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] 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
Hi, It's not clear what you mean by summary text without a minimal reproducible example. If your text is ordered as a matrix or a data.frame, you might want to try this grid function, gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white()) If your text has the form of a paragraph, t

Re: [R] Plot multiple columns

2010-06-01 Thread baptiste auguie
Hi, You could use melt from the reshape package to create a long format data.frame. This is more easy to plot with lattice or ggplot2, and you can then use facetting to arrange several plots on the same page. The dummy example below produces 10 pages of output with 10 graphs per page. library(ggp

Re: [R] Faster matrix operation?

2010-06-01 Thread baptiste auguie
On 1 June 2010 11:34, Peter Ehlers wrote: > Or, for a very slight further reduction in time in > the case of larger matrices/vectors: > >  as.vector(tcrossprod(V, xyzs)) > > I mention this merely to remind new users of the > excellent speed of [t]crossprod(). > >  -Peter Ehlers Thanks, I've been

Re: [R] Fancy Page layout

2010-05-31 Thread baptiste auguie
Hi, ggplot2 or lattice could help you in creating the plots. Adding a summary will however require some play with Grid graphics; either using gridBase to mix lattice / ggplot2 output with base R graphics (e.g. textplot() from some package I forget), or you'll need to produce the textual summary i

Re: [R] x y plot with z coordinate scaling to a color value

2010-05-19 Thread baptiste auguie
Hi, See also ?lattice::xyplot and ?ggplot2::geom_point , either one can do it automatically. HTH, baptiste On 19 May 2010 12:24, Jannis 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

Re: [R] substitute, expression and factors

2010-05-18 Thread baptiste auguie
Thank you for the explanation, and the fortune-ish quote, “As the documentation for substitute() says, there is no guarantee that the result makes sense.” Best, baptiste On 19 May 2010 02:59, Duncan Murdoch wrote: > On 18/05/2010 4:36 PM, baptiste auguie wrote: >> >> Dear l

[R] substitute, expression and factors

2010-05-18 Thread baptiste auguie
Dear list, I am puzzled by this, substitute(expression(x), list(x = factor(letters[1:2]))) # expression(1:2) Why do I get back the factor levels inside the expression and not the labels? The following work as I expected, substitute(expression(x), list(x = letters[1:2])) # expression(c("a", "b")

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

2010-05-18 Thread baptiste auguie
On 18 May 2010 15:30, Deepayan Sarkar wrote: > Maybe a better test would be > > isTRUE(all.equal(diff(range(diff(ux))), 0)) > > I'll try that out for the next release. > Sounds good (and works for me), thanks. baptiste __ R-help@r-project.org mailin

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

2010-05-18 Thread baptiste auguie
Dear all, I got a couple of warnings using panel.levelplot.raster, In panel.levelplot.raster(..., interpolate = TRUE) : 'y' values are not equispaced; output will be wrong although I was quite sure my data were equally spaced (indeed, I created them with seq()). A closer look at the source cod

Re: [R] how to save multiple plots in one PDF file?

2010-05-17 Thread baptiste auguie
No, that's only true for lattice and ggplot2 graphics. The problem here is with this line, windows(width=5, height=5) which shouldn't be there. HTH, baptiste On 17 May 2010 22:23, Jun Shen wrote: > If you do plotting in a loop, then you need to print it to the device. > > print(plot(xj,y)) >

Re: [R] Display Large Matrix as an Image

2010-05-17 Thread baptiste auguie
Hi, try this, m = matrix(runif(2000*2400), nrow=2000) library(grid) grid.raster(m) HTH, baptiste On 17 May 2010 20:35, tetonedge wrote: > > I have a matrix that is 2400x2000 and I would like to display it as an image, > I have tried image(), but due to the size of the matrix the drawing of t

Re: [R] retrieving last R output

2010-05-17 Thread baptiste auguie
Hi, Try this, saveMyWork <- .Last.value HTH, baptiste On 17 May 2010 15:07, math_daddy wrote: > > Hello. > > I ran a simulation that took a few days to complete, and want to analyze the > results, but have just realized that I (idiotically) did not assign the > output to a variable when I int

Re: [R] problem with making multiple plots (geom_pointrange) in a loop (ggplot2)

2010-05-16 Thread baptiste auguie
Hi, On 16 May 2010 03:31, michael westphal wrote: [ snipped ] > Any suggestions? > i'd suggest you - read the posting guide - upgrade your R to the latest version - don't post to two mailing lists - make your example minimal, self-contained, reproducible - show the result of sessionInfo() HTH,

Re: [R] graphics::plot Organizing line types, line colors and generating matching legends...

2010-05-10 Thread baptiste auguie
Hi, Lattice and ggplot2 are both ideally suited for this task. Consider this example, library(ggplot2) d = data.frame(x=1:10, a1=rnorm(10), b1=rnorm(10)) m = melt(d, id ="x") # reshape into long format qplot(x, value, data=m, geom="path", colour=variable) library(lattice) xyplot(value~x, data=m

Re: [R] R2.11.0 - rasterImage() and barplot fill-patterns

2010-04-22 Thread baptiste auguie
Hi, This idea was also discussed when Paul Murrell first announced the grid.raster function to R-devel, http://tolstoy.newcastle.edu.au/R/e8/devel/09/12/0912.html My personal conclusion was that vector fill patterns are generally better in terms of resolution and speed. Of course the situation mi

Re: [R] Words appear to be bolded in the PDF output

2010-04-20 Thread baptiste auguie
Hi, Taking a wild guess, it looks to me that you might have overlaid several times the same text, plot.new() text(0.5,0.5,rep("test",10)) HTH, baptiste On 20 April 2010 08:54, chrisli1223 wrote: > > Hi all, > > I have written a note near each of my graphs using mtext. > mtext(text,side=1,line

Re: [R] How to embed italic Greek letters in a eps file?

2010-04-19 Thread baptiste auguie
Hi, Another option might be the tikzDevice package, which uses LaTeX to process the fonts, library(tikzDevice) tikz(standAlone=T) plot(1,1, type = 'n') mtext(side = 3, line = 2, "$\\mu$") dev.off() ## system("/usr/texbin/pdflatex Rplots.tex") HTH, baptiste On 20 April 2010 07:30, Prof Brian R

Re: [R] Exporting an rgl graph

2010-04-15 Thread baptiste auguie
t; > luke > > > On Thu, 15 Apr 2010, baptiste auguie wrote: > >> I have seen pdf files with 3D objects embedded in it, using the U3D >> format, >> http://en.wikipedia.org/wiki/Universal_3D >> >> but I don't think there's a device for this in R; in f

Re: [R] Exporting an rgl graph

2010-04-15 Thread baptiste auguie
I have seen pdf files with 3D objects embedded in it, using the U3D format, http://en.wikipedia.org/wiki/Universal_3D but I don't think there's a device for this in R; in fact there may not even exist a third-party post-processing route available at this time to bridge the gap between rgl and this

Re: [R] Figures within tables [slightly off-topic]

2010-04-12 Thread baptiste auguie
Hi, On 12 April 2010 22:07, Peter Jepsen wrote: > > 3. Are there R packages that can "draw tables"? the gplots package has a textplot() function, and the gridExtra package a tableGrob(), http://rwiki.sciviews.org/doku.php?id=tips:graphics-grid:table In theory it should be possible to adapt the

Re: [R] square root of inverse

2010-04-08 Thread baptiste auguie
try this, install.packages("expm", repos="http://R-Forge.R-project.org";) On 8 April 2010 17:28, arindam fadikar wrote: > On Thu, Apr 8, 2010 at 5:38 PM, David Winsemius wrote: > >> >> On Apr 8, 2010, at 1:45 AM, arindam fadikar wrote: >> >>  Dear users, >>> >>> How to get a symmetric square roo

Re: [R] It This data viz possible in R?

2010-04-08 Thread baptiste auguie
, SIMPLIFY=FALSE)) gTree(children=gList(g1, g2, g3), outer.radius=convertUnit(radius, "npc") + convertUnit(max(stringWidth(labels)), "npc")) } grid.arcText <- function(...) grid.draw(arcTextGrob(...)) set.seed(1234) grid.newpage() grid.arcText()

Re: [R] It This data viz possible in R?

2010-04-07 Thread baptiste auguie
w() grid.arcText(labels=labels) On 7 April 2010 16:44, Gabor Grothendieck wrote: > There is draw.arc in the plotrix package. > > On Wed, Apr 7, 2010 at 10:20 AM, baptiste auguie > wrote: >> Hi, >> >> Barry suggested a way to place the text labels; I would like to

Re: [R] It This data viz possible in R?

2010-04-07 Thread baptiste auguie
Hi, Barry suggested a way to place the text labels; I would like to point out the grid.curve() function that might help in connecting the labels with nice-looking curves. I don't know of a base graphics equivalent (xspline() might come close) so it might be best to opt for Grid. HTH, baptiste

Re: [R] Aligning text in the call to the text function

2010-04-01 Thread baptiste auguie
Hi, One option with Grid graphics, m <- matrix(c( 1667,3,459, 2001, 45, 34, 1996, 2,5235), dimnames=list(c("Eric & Alan", "Alan","John & David")), ncol=3, byrow=T) ## install.packages("gridExtra", repos="http://R-Forge.R-project.org";) library(gri

Re: [R] lattice grob

2010-03-25 Thread baptiste auguie
Hi, On 24 March 2010 23:22, Paul Murrell wrote: > Hi > > baptiste auguie wrote: >> >> Thanks Felix and Paul. I had overlooked grid.grabExpr, assuming that >> one had to draw on a device before grabbing the output. >> >> Now I'm not sure if there'

Re: [R] lattice grob

2010-03-22 Thread baptiste auguie
> 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, b

Re: [R] multiple logical comparisons

2010-03-21 Thread baptiste auguie
try this one, `%ni%` <- Negate(`%in%`) Best, baptiste __ 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-c

[R] lattice grob

2010-03-19 Thread baptiste auguie
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 trelli

Re: [R] write.fortran

2010-03-10 Thread baptiste auguie
# test - m is from original post > write.mat(m, rep(c("%i", "  %15.7e", "\n"), c(1, 6, 1)), file = "") > > > On Wed, Mar 10, 2010 at 7:52 AM, baptiste auguie > wrote: >> Thanks, it is indeed a bit cleaner. I was hoping for a more gene

Re: [R] write.fortran

2010-03-10 Thread baptiste auguie
Thanks, it is indeed a bit cleaner. I was hoping for a more generic solution but I guess people use cat() and sprintf() in such cases. Thanks, baptiste On 10 March 2010 12:46, Berend Hasselman wrote: > > > > baptiste auguie-5 wrote: >> >> >> This is a lot easier &

Re: [R] ggplot2: Changing colour scheme for bar plot filling?

2010-03-10 Thread baptiste auguie
; > thanks for your help, Joh > > On Wednesday 10 March 2010 10:29:05 baptiste auguie wrote: >> Hi, >> >> last_plot() + scale_fill_grey() >> >> should do it >> >> HTH, >> >> baptiste >> >> On 10 March 2010 09:46, Johannes Gra

Re: [R] ggplot2: Changing colour scheme for bar plot filling?

2010-03-10 Thread baptiste auguie
Hi, last_plot() + scale_fill_grey() should do it HTH, baptiste On 10 March 2010 09:46, Johannes Graumann wrote: > Hello, > > I'd like to sitch to a monochrome/bw color-palette for the filling of > geom_bar-bars (produced via "qplot" as in the example below). Hours of > googling didn't yield a

[R] write.fortran

2010-03-10 Thread baptiste auguie
Dear all, I'm trying to write tabular data to a text file, these data will be the input of a Fortran program. The format needs to be "(i7,2x,7(e15.7,2x))". I have not been able to find a clean way of producing this output with write.table. I searched for a "write.fortran" function similar to read.

Re: [R] How to take out the content of character string

2010-03-10 Thread baptiste auguie
Hi, it's generally considered a bad practice but try this, eval(parse(text=AA)) library(fortunes) fortune(106) HTH, baptiste On 10 March 2010 07:46, jq81 wrote: > > My question is represented by the following example. > > For example, I have a character string a, which is defined as > > AA="

Re: [R] data.frame question

2010-03-07 Thread baptiste auguie
Hi, try this, data.frame(x,as.numeric(x %in% y)) HTH, baptiste On 7 March 2010 21:06, joseph wrote: > hello > > can you show me how to create a data.frame from two factors x and y. column 1 > should be equal to x and column 2 is 1 if it is common to y and 0 if it is > not. > > x=factor(c("A

Re: [R] how to make this sequence: 1,2,3,4,5,4,3,2,1

2010-03-05 Thread baptiste auguie
c(x <- 1:5, rev(x[-length(x)])) On 5 March 2010 07:04, kensuguro wrote: > > I'm just beginning R, with book Using R for Introductory Statistics, and one > of the early questions has me baffled.  The question is, create the > sequence: 1,2,3,4,5,4,3,2,1 using seq() and rep(). > > Now, as a progr

Re: [R] Three most useful R package

2010-03-03 Thread baptiste auguie
Hi, The 3 packages I load most often are my own; typically I make a new package for every new job. It automatically loads other packages as dependencies (top-ranked are ggplot2, reshape, plyr) as well as my data and functions I'm currently working with. If some functions evolve further towards a

Re: [R] Preserving lists in a function

2010-02-27 Thread baptiste auguie
Point well taken --- grid::gpar() is also a good example; I'll make use of your suggestion in my future coding. Best, baptiste On 27 February 2010 15:02, Barry Rowlingson wrote: > On Sat, Feb 27, 2010 at 11:29 AM, Gabor Grothendieck > wrote: >> Or use modifyList which is in the core of R. > >

Re: [R] Preserving lists in a function

2010-02-27 Thread baptiste auguie
Hi, I think I would follow this approach too, using updatelist() from the reshape package, updatelist <- function (x, y) { common <- intersect(names(x), names(y)) x[common] <- y[common] x } myfunction=function(list1=NULL, list2=NULL, list3=NULL){ list1=updatelist(list(variable1=1

Re: [R] Plotting a Trivial Matrix

2010-02-26 Thread baptiste auguie
On 26 February 2010 11:12, Lorenzo Isella wrote: > Thanks Augustine and Jim for the prompt reply. > You both answered my question. To avoid another post, I would simply like to > know if something along these lines is doable also with ggplot2. > Many thanks > > Lorenzo > Augustine??? Anyhow, wi

Re: [R] Plotting a Trivial Matrix

2010-02-26 Thread baptiste auguie
Hi, A minimalist example using Grid graphics, library(RGraphics) bwImage <- function(m, cols=c("white", "black"), draw=TRUE, gp=gpar()){ g <- imageGrob(nrow(m), ncol(m), cols=cols[m+1], gp=gp) if(draw) grid.draw(g) return(g) } m <- matrix(rnorm(200) > 0,

Re: [R] How to fill in a region with different patterns?

2010-02-25 Thread baptiste auguie
Hi, If you are curious you might like to try a highly experimental Grid function I wrote some time ago, library(grid) source("http://gridextra.googlecode.com/svn/trunk/R/patternGrob.r";) grid.newpage() grid.pattern(x=seq(1/6, 5/6, length=6), width=unit(1/8,"npc"), height=unit(0.5,"npc"),

Re: [R] Exporting Graphs

2010-02-21 Thread baptiste auguie
Hi, just to make sure, you didn't forget to close the device with dev.off() ? baptiste On 21 February 2010 20:48, Karthik wrote: > Hello Tal, > This is the code. > > >> hist(rnorm(100)) >> jpeg("histogram.jpeg") > --- > > Even when I decrease the qua

Re: [R] Bind field of a list

2010-02-19 Thread baptiste auguie
Hi, Try this, unlist(test) or do.call(c, test) HTH, baptiste On 19 February 2010 15:19, statquant wrote: > > Hello all > I am new in R and so easy stuff are difficult... > let say that I have a list > test <- list(a=c("x","v"),b=c("n","m")) > how can I without a loop get test$a bind with te

Re: [R] unexpected results with higher-order functions and lapply

2010-02-14 Thread baptiste auguie
Hi, I believe it's lazy evaluation. See ?force HTH, baptiste On 14 February 2010 20:32, Jyotirmoy Bhattacharya wrote: > I want to use lapply and a function returning a function in order to build a > list of functions. > >> genr1 <- function(k) {function() {k}} >> l1 <- lapply(1:2,genr1) >> l1[

Re: [R] Problems with boxplot in ggplot2:qplot

2010-02-14 Thread baptiste auguie
Hi, it's hard to tell what's wrong without a reproducible example, but I noted two things: - AFAIK there is no plot method for ggplot2. You probably meant print(p) instead - if you map x to factor(month), I think it will be incompatible with your xlim values range(month). HTH, baptiste On 14

Re: [R] evaluate variable within expression - how?

2010-02-14 Thread baptiste auguie
Hi, Try with bquote, plot.new() myText <- "some text" text(.5, .5, bquote(bold(.(myText basically, bquote( .(myText) ) performs the substitution before applying bold() (see ?bquote). HTH, baptiste On 14 February 2010 17:36, Mark Heckmann wrote: > #  I want to plot bold text. The text sh

Re: [R] Flattening Graphics

2010-02-11 Thread baptiste auguie
Hi, On 11 February 2010 22:14, Paul Murrell wrote: > Hi > > > baptiste auguie wrote: >> >> Hi, >> >> You could try the grid.grab() function in R devel if your graphics use >> the Grid package. It will read the graphical output as a bitmap which > >

Re: [R] Flattening Graphics

2010-02-10 Thread baptiste auguie
Hi, You could try the grid.grab() function in R devel if your graphics use the Grid package. It will read the graphical output as a bitmap which you can then export in a multipage pdf. It may not be really flattening per se but that would definitely help with the viewing speed. HTH, baptiste O

Re: [R] color blending and transparency

2010-02-03 Thread baptiste auguie
Thanks for this complementary information. My head itches slightly when reading about these virtual layers with unidirectional absorption and reflection properties but I guess that's imputable to my personal background as a physicist. I still have a few questions, - is this behavior documented? (

Re: [R] color blending and transparency

2010-02-03 Thread baptiste auguie
ource code later (I haven't found any documentation on this so far). Thanks, baptiste On 3 February 2010 16:38, Duncan Murdoch wrote: > On 03/02/2010 9:38 AM, baptiste auguie wrote: >> >> That makes perfect sense, thank you, except that I'm not sure where >> the whit

Re: [R] color blending and transparency

2010-02-03 Thread baptiste auguie
On 3 February 2010 15:17, Duncan Murdoch wrote: > On 03/02/2010 8:50 AM, Ken Knoblauch wrote: >> >> baptiste auguie googlemail.com> writes: >>> >>> Adding two semi-transparent colours results in non-intuitive colour >>> mixing (a mystery for

Re: [R] group factor levels

2010-02-03 Thread baptiste auguie
As always the question seems silly after you've learned the answer! Thanks a lot, baptiste On 3 February 2010 15:06, Petr PIKAL wrote: > # order levels > f.t<-factor(f, levels=disorder) > # change levels > levels(f.t) <- new.lev > all.equal(f.t,f2) > [1] TRUE > > > Regards > Petr > > >> >> Bes

[R] group factor levels

2010-02-03 Thread baptiste auguie
Dear list, I cannot find an elegant solution to this problem. I have a factor f containing several levels (5) and I wish to create a new factor of the same length with fewer levels (2). This new factor should therefore group together some levels of the original data. Ideally this grouping would be

Re: [R] color blending and transparency

2010-02-03 Thread baptiste auguie
Hi, Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two "layers" the overlap region is either purple or dark red. I h

Re: [R] parsing files for plot

2010-01-30 Thread baptiste auguie
d(comb,combadd) > > } > boxplot(dats ~ index, data = comb) > > > works just great. There is no additional files in the folder. But look, how > much code for such a simple task. I'd definitely prefer the plyr solution. > > Maxim > > > 2010/1/30 baptiste auguie &g

Re: [R] parsing files for plot

2010-01-30 Thread baptiste auguie
Hi, Hadley recently proposed a strategy using plyr for a very similar problem, listOfFiles <- list.files() names(listOfFiles) <- basename(listOfFiles) library(plyr) d <- ldply(listOfFiles, scan) Even if you don't want to use plyr, it's always better to group things in a list rather than clutter

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread baptiste auguie
Hi, Would this do as an alternative syntax? g1 <- quote(1/Tm) mat <- list(0, bquote(f1*s1*.(g1))) vals <- data.frame(f1=1, s1=.5, Tm=2) sapply(mat, eval, vals) HTH, baptiste On 29 January 2010 17:51, Jennifer Young wrote: > Hallo > > I'm having trouble figuring out how to evaluate an expres

Re: [R] quartz() and dpi

2010-01-28 Thread baptiste auguie
Hi, I think it's a bug in quartz(). The following example uses png() with cairo or quartz backends, and only cairo respects the size and resolution (as verified in Adobe Photoshop). png(file="foo-300.png", type="quartz", units="in",width=5, height=3, res=300) plot(1,1) dev.off() png(file="fo

Re: [R] color matrix

2010-01-27 Thread baptiste auguie
Hi, It's easy with ggplot2, cols = matrix(c("#F7FBFF", "#DEEBF7", "#C6DBEF", "#9ECAE1", "#6BAED6", "#4292C6", "#2171B5", "#08519C" ,"#08306B"), ncol=3) library(ggplot2) m = melt(cols) qplot(factor(X1),factor(X2),data=m, fill=value, geom="tile") + scale_fill_identity() HTH, baptiste 2010/1/2

Re: [R] ggplot2 theme for custom point colors?

2010-01-27 Thread baptiste auguie
Hi, I remember asking a similar question some time ago, I don't know if the matter has evolved since then, http://groups.google.com/group/ggplot2/browse_frm/thread/a3df8a0d1ee335fb/e3bedd50fb9bd567?lnk=gst&q=theme#e3bedd50fb9bd567 There's also set_default_scale, somewhat related to your question

Re: [R] Fwd: Re: Graph color

2010-01-26 Thread baptiste auguie
Hi, Try this, x <- seq(0, 10, len = 100) y <- jitter(sin(x), 1000) old.par <- par() par(bg=grey(0.5)) plot(x, y, new = TRUE, t = "n") lims <- par("usr") plot(x, y, col = 1, panel.first = { rect(lims[1], lims[3], lims[2], lims[4], col = "lightblue") }) HTH, baptiste 2010/1/26 :

Re: [R] column selection in list

2010-01-22 Thread baptiste auguie
lected ("y"). Best, baptiste 2010/1/22 Ivan Calandra : > Thanks Baptiste, it does help. > > However, I don't really understand what "[" means. Could you please tell me > more about it? I didn't find anything helpful on that in the help. > > Thanks in

Re: [R] column selection in list

2010-01-22 Thread baptiste auguie
Hi, Try this, a = replicate(3, data.frame(x=1:10, y=rnorm(10)), simplify=FALSE) lapply(a, "[", "y") HTH, baptiste 2010/1/22 Ivan Calandra : > Hi everybody! > > I have a (stupid) question but I cannot find a way to do it! > > I have a list like: >> SPECSHOR_tx_Asfc > $cotau >   SPECSHOR Asfc.m

Re: [R] about loops

2010-01-21 Thread baptiste auguie
Hi, One approach could be a while loop as follows. Note that your circle should have radius 0.5 if I understood the problem correctly. N <- 5 npoints <- 0 ntests <- 0 points.in.circle <- matrix(NA, ncol=2, nrow=N) while (npoints < N) { test.point <- runif(2, -0.5, 0.5) # generate new point

Re: [R] How do I juxtapose two lattice graphs with common X axes such that the X axes line up?

2010-01-20 Thread baptiste auguie
Hi, try c.trellis() from the latticeExtra package. HTH, baptiste 2010/1/20 George Chen : > Hello, > > I would like to juxtapose two lattice graphs with common X axes such that the > X axes line up.  I am using plot right now but the edges are not neat and it > would be nice if I could just d

Re: [R] apply command

2010-01-19 Thread baptiste auguie
Hi, I think you could use iapply (search the archives) or the plyr package to save you from transposing the result. HTH, baptiste 2010/1/19 marco salvini : > Can you please help on the issue? > I using the apply command on a matrix below the example: > > Create a vector > x =c(5, 3, 2:4, NA, 7,

Re: [R] call R with un expression (String)?

2010-01-19 Thread baptiste auguie
Hi, ?eval seems like a good candidate HTH, baptiste 2010/1/15 Jiiindo : > > Hello all, > I want to call R from java. And I have a expression in Java as a String, > example : (variable 1 + variable 2)* variable 3 and i want R calculate this > expression. How can I do? > ex: > Java > -int x1,x2;

Re: [R] exporting text output to pdf

2010-01-19 Thread baptiste auguie
Hi, You could play with the splitTextGrob() function from the RGraphics package, string <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo ipsum, ultricies scelerisque volutpat non, volutpat et nulla. Curabitur consequat ullamcorper tellus id imperdiet. Duis semper malesuada

Re: [R] expand.grid game

2010-01-13 Thread baptiste auguie
It did take me a good night's sleep to understand it. I was stuck with the exact same question but I see now how the remaining balls are shared among all 8 urns (therefore cases with 11, 12, 13, ... 17 balls are also dealt with). Thanks again, baptiste 2010/1/12 Rolf Turner : > > On 13/01/2010,

Re: [R] expand.grid game

2010-01-12 Thread baptiste auguie
...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Brian Diggs >> Sent: Thursday, December 31, 2009 3:08 PM >> To: baptiste auguie; David Winsemius >> Cc: r-help >> Subject: Re: [R] expand.grid game >> >> baptiste auguie wrote: >> &

Re: [R] postscript, greek lellters

2010-01-09 Thread baptiste auguie
Hi, Something like this maybe, plot.new() lab = expression(bar(T)*"("*-x*" ; "*alpha*")"-G*"("*x*" ; "*alpha*" , "*J*")") text(0.5,0.5,lab) ?plotmath HTH, baptiste 2010/1/8 bernardo lagos alvarez : > Dear useRs, > > How can I, writting the correct greek letter using postscrip or pdf functio

Re: [R] [R-pkgs] fortunes: 250th fortune

2010-01-07 Thread baptiste auguie
Hi, Thank you for this fun package. I recently posted a related question on R-help that seemed to pass unnoticed. Basically, I suggested that the functionality of fortunes could be extended to R FAQ entries, also allowing contributed packages to provide their own (fortune or) faq data file. My ini

Re: [R] xyplot: problems with column names & legend

2010-01-03 Thread baptiste auguie
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 : > Hello! > > one more

Re: [R] Axis Labels for Compound Plots in ggplot2

2009-12-30 Thread baptiste auguie
Hi, You can set up a Grid layout with one viewport at the bottom and another on the left and use grid.text to add your labels. An example is given below using grid.pack. The gridExtra package provides a convenient wrapper for these regular arrangements of plots, ##library(gridExtra) #http://grid

Re: [R] Histogram/BoxPlot Panel

2009-12-29 Thread baptiste auguie
as well as a book. Lattice also has a dedicated book, and a companion website with the figures, http://r-forge.r-project.org/projects/lmdvr/ HTH, baptiste 2009/12/29 baptiste auguie : > Hi, > > Here is some artificial data followed by minimal ggplot2 and lattice examples, > > make

Re: [R] Histogram/BoxPlot Panel

2009-12-29 Thread baptiste auguie
Hi, Here is some artificial data followed by minimal ggplot2 and lattice examples, makeUpData <- function(){ data.frame(x=sample(letters[1:4], 100, repl=TRUE), y=rnorm(100)) } datasets <- replicate(15, makeUpData(), simplify=FALSE) names(datasets) <- paste("dataset", seq_along(datasets), sep

Re: [R] subsetting by groups, with conditions

2009-12-29 Thread baptiste auguie
Hi, I think you can also use plyr for this, dft <- read.table(textConnection("P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5 4")

Re: [R] ggplot2, building a simple formula interface

2009-12-29 Thread baptiste auguie
Hi, Try print(p) instead of plot(p) HTH, baptiste 2009/12/29 Bryan Hanson : > I¹m trying to build a simple formula interface to work with a function using > ggplot2. The following scheme ³works² up until the plot(p) request, at which > point there are complaints about xlim¹s and a blank graphic

Re: [R] Scaling error

2009-12-27 Thread baptiste auguie
Hi, Try this, x <- matrix(1:9, ncol=3, byrow=T) sca <- c(2.5, 1.7, 3.6) x %*% diag(1/sca) HTH, baptiste 2009/12/27 Muhammad Rahiz : > Hi useRs, > > I ran into an inconsistent output problem again. Here is the simplify > illustration > > I've got a matrix as follows > >> x >       V1    V2  

Re: [R] String question

2009-12-23 Thread baptiste auguie
Isn't paste doing exactly this? temp <- c("November", "December","Monday","Tuesday") paste(temp, collapse=",") # "November,December,Monday,Tuesday" HTH, baptiste 2009/12/23 Ted Harding : > On 23-Dec-09 11:08:02, Knut Krueger wrote: >> Jim Lemon schrieb: >>> Not as easy as I thought it would be

Re: [R] String question

2009-12-23 Thread baptiste auguie
Will this do? temp <- paste("m", 1:3, sep="",collapse=",") HTH, baptiste 2009/12/23 Knut Krueger : > Hi to all > > I need a string like > temp <- paste("m1","m2","m3",sep=",") > But i must know how many items are in the string,afterwards > the other option would be to use a vector > temp <- c("

Re: [R] expand.grid game

2009-12-21 Thread baptiste auguie
rybody who participated, I have learned interesting things from a seemingly innocuous question. Best regards, baptiste 2009/12/21 Robin Hankin : > Hi > > library(partitions) > jj <- blockparts(rep(9,8),17) > dim(jj) > > gives 318648 > > > HTH > > rk

Re: [R] How to rotate an axis?

2009-12-20 Thread baptiste auguie
Hi, Do you want a ternary plot? http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=34 It's easy to rotate an axis with Grid graphics, library(grid) pushViewport(viewport(0.5,0.5, width=0.5, height=unit(3, "lines"))) grid.xaxis(at=seq(-0.5,0.5,by=0.1), vp=viewport(x=1, angle=-60)) HTH

Re: [R] basic proto question

2009-12-20 Thread baptiste auguie
to refer to stats::predict.  Change the line that calls predict to: > > stats::predict(.$spline(), x.fine) > > On Sun, Dec 20, 2009 at 11:49 AM, baptiste auguie > wrote: >> Dear list, >> >> I made the following example of a proto object that contains some data >>

[R] basic proto question

2009-12-20 Thread baptiste auguie
Dear list, I made the following example of a proto object that contains some data and a spline interpolation. I don't understand why test$predict() fails with this error message: Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Best regards, baptiste test <- pro

Re: [R] expression()

2009-12-20 Thread baptiste auguie
Hi, try this, ylab = expression(Temperature~(degree*F)) ?plotmath baptiste 2009/12/20 Kim Jung Hwa : > Hi All, > > I'm wondering if its possible to write degree in symbol. > > I would like y-label as "Temperature (degreeF)". where degree should be in > symbols. Thanks in advance, > > #R Code >

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
) p Best, baptiste [David: sorry for the duplicate, i initially sent an attachment that was too large for the list] > 2009/12/19 David Winsemius : >> >> On Dec 19, 2009, at 2:10 PM, David Winsemius wrote: >> >>> >>> On Dec 19, 2009, at 1:36 PM, baptiste

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
)==17) {idx<-c(idx,i)}) user system elapsed 34.050 1.109 35.791 I'm surprised by idx<-c(idx,i), isn't that considered a sin in the R Inferno? Presumably growing idx will waste time for large N. Thanks, baptiste 2009/12/19 David Winsemius : > > On Dec 19, 2009, at 1:36

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
2009/12/19 David Winsemius : > > On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote: > >> Dear list, >> >> In a little numbers game, I've hit a performance snag and I'm not sure >> how to code this in C. >> >> The game is the following: h

[R] expand.grid game

2009-12-19 Thread baptiste auguie
Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the following: how many 8-digit numbers have the sum of their digits equal to 17? The brute-force answer could be: maxi <- 9 # digits from 0 to 9 N <- 5 # 8 is too large test <- 1

Re: [R] mutlidimensional in.convex.hull (wasmultidimensionalpoint.in.polygon??)

2009-12-18 Thread baptiste auguie
Hi, Excellent, thanks for doing this! I had tried the 2D case myself but I was put off by the fact that Octave's convhulln had a different ordering of the points to R's geometry package (an improvement to Octave's convhulln was made after it was ported to R). I'm not sure how you got around this

[R] fortune-like FAQ search

2009-12-16 Thread baptiste auguie
Dear list, I'm not so familiar with the internals of the fortunes package, but I really like the interface. I was wondering if someone had implemented a similar functionality to parse the entries of the R FAQ < http://cran.r-project.org/doc/FAQ/R-FAQ.html >. Say, if I was to answer a question "Wh

Re: [R] problem with a densityplot

2009-12-16 Thread baptiste auguie
FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f you need to print() HTH, baptiste 2009/12/16 c...@autistici.org : > Hi, > i have a script how i launch lattice to make a densityplot. > in the script: > > jpeg(file="XXX.jpg") > densityplot(~f_di

Re: [R] Combinations

2009-12-14 Thread baptiste auguie
Hi, Try this, apply(expand.grid(letters[1:3], letters[24:26]), 1, paste,collapse="") [1] "ax" "bx" "cx" "ay" "by" "cy" "az" "bz" "cz" ?expand.grid HTH, baptiste 2009/12/14 Amelia Livington : > > Dear R helpers, > > I am working on the scenario analysis pertaining to various interest rates. >

Re: [R] code for [[.data.frame

2009-12-13 Thread baptiste auguie
`[[.data.frame` and more generally see Rnews Volume 6/4, October 2006 "Accessing the Sources". HTH, baptiste 2009/12/13 Guillaume Yziquel : > Hello. > > I'm currently trying to wrap up data frames into OCaml via OCaml-R, and I'm > having trouble with data frame subsetting: > >> # x#column 1;;

<    1   2   3   4   5   6   7   8   >