[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] 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

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] 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
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? (

[R] replicate a grob n times

2010-06-16 Thread baptiste auguie
Dear all, I use the following to create a list of identical grobs, require(grid) rep.grob <- function(g, n){ replicate(n, g, simplify=FALSE) } This approach suffers two problems: 1- R CMD check is not happy about the S3-like name. How can / Should I make this a real S3 method? 2- I don't know

Re: [R] Drawing paths through a grid

2010-06-17 Thread baptiste auguie
Hi, Try this, ## create a 2D grid with random point sizes d = expand.grid(x=1:10,y=1:10) d$size = runif(nrow(d), 1,5) ## create some random links links= d[sample(seq(1,nrow(d)),20),] links$id = sample(2:6, nrow(links),repl=T) ## plot library(ggplot2) ggplot(d, mapping=aes(x,y)) + geom_point(

Re: [R] ggplot2 boxplot: horizontal, univariate

2010-06-18 Thread baptiste auguie
Try this, qplot(factor(0), mpg, data=mtcars, geom="boxplot", xlab="")+ coord_flip() + scale_x_discrete(breaks=NA) HTH, baptiste On 18 June 2010 16:47, Jacob Wegelin wrote: > > In ggplot2, I would like to make a boxplot that has the following > properties: > > (1) Contrary to default, the meanin

Re: [R] More than two font in a plot

2010-06-30 Thread baptiste auguie
Hi, Another option would be the tikzDevice package, which lets you process all the text of your plot with LaTeX. I think the XeTeX variant might be the most straight-forward to mix different fonts using this approach. HTH, baptiste On 29 June 2010 16:17, Jinsong Zhao wrote: > Hi there, > > I

Re: [R] Bug 14340 - Symbols() plots with wrongly scaled y-axis

2010-07-17 Thread baptiste auguie
Hi, try adding asp=1 in symbols() to set the aspect ratio of the plotting region to 1. HTH, baptiste On 17 July 2010 18:21, wrote: > Hello, I submitted this bug report to r-core and got a rejection saying I > should post to r-help. > This is my first time ever submitting a bug report, so for

Re: [R] R graphic help

2010-07-18 Thread baptiste auguie
Hi, There may be a simpler way but try this, plot(10^jitter(seq(-2,4,length=10)), 1:10, log="x", xaxt="n") axis(1, at = axTicks(1),labels = format(axTicks(1),scientific=FALSE)) HTH, baptiste On 18 July 2010 10:58, Timothy O'Brien wrote: > Dear All, > > I've done some searching, but to no avai

[R] scalable < > delimiters in plotmath

2010-09-09 Thread baptiste auguie
Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails with < > however, and I cannot find a workaround, grid.text(expression(bgroup("<",atop(x,y),">"))) Error in bgroup("<", atop(x, y), ">") : invalid group delimiter Regar

Re: [R] scalable < > delimiters in plotmath

2010-09-11 Thread baptiste auguie
What do people use to show angle brackets < > in R graphics? Have I missed something obvious? Thanks, baptiste On 9 September 2010 17:57, baptiste auguie wrote: > Dear list, > > I read in ?plotmath that I can use bgroup to draw scalable delimiters > such as [ ] and ( ).

Re: [R] scalable < > delimiters in plotmath

2010-09-12 Thread baptiste auguie
7;x, y'~symbol("\076"))) >>> >>> HTH, >>> Dennis >> >> It's a matter of taste, but I would use "\341" and "\361". >> However, these are still not scalable, AFAICS. > > Not exactly scalable angles, but you ca

Re: [R] scalable < > delimiters in plotmath

2010-09-12 Thread baptiste auguie
p 12, 2010, at 6:15 AM, baptiste auguie wrote: > >> Thanks everyone. I've also had a look at plotmath.c where bgroup is >> defined for "[", "{", "(", "." but not "<". It seems quite trivial to >> add it, at first sight, however

Re: [R] scalable < > delimiters in plotmath

2010-09-12 Thread baptiste auguie
I see, thanks. Looking at this table I guess the short answer is no, these cannot be made to scale and the only ones that could have already been implemented in bgroup(). Thanks, baptiste On 12 September 2010 22:11, Paul Murrell wrote: > Hi > > On 13/09/2010 7:57 a.m., baptiste aug

[R] bivariate vector numerical integration with infinite range

2010-09-21 Thread baptiste auguie
Dear list, I'm seeking some advice regarding a particular numerical integration I wish to perform. The integrand f takes two real arguments x and y and returns a vector of constant length N. The range of integration is [0, infty) for x and [a,b] (finite) for y. Since the integrand has values in R

[R] puzzle with integrate over infinite range

2010-09-21 Thread baptiste auguie
Dear list, I'm calculating the integral of a Gaussian function from 0 to infinity. I understand from ?integrate that it's usually better to specify Inf explicitly as a limit rather than an arbitrary large number, as in this case integrate() performs a trick to do the integration better. However,

Re: [R] bivariate vector numerical integration with infinite range

2010-09-21 Thread baptiste auguie
,0) > [1] NaN NaN NaN > Warning message: > In sqrt(x) : NaNs produced >>  f(-3.9,0.1) > [1] NaN NaN NaN > Warning message: > In sqrt(x) : NaNs produced > -- > David > On Sep 21, 2010, at 4:11 AM, baptiste auguie wrote: > >> Dear list, >> >>

Re: [R] bivariate vector numerical integration with infinite range

2010-09-21 Thread baptiste auguie
Recipes. Thanks, baptiste On 21 September 2010 14:26, Hans W Borchers wrote: > baptiste auguie googlemail.com> writes: > >> >> Dear list, >> >> I'm seeking some advice regarding a particular numerical integration I >> wish to perform. >> >&

Re: [R] puzzle with integrate over infinite range

2010-09-21 Thread baptiste auguie
I see, thank you. I'm still worried by the very dramatic error I obtained just from shifting so slightly the support of the integrand, it took me a while to figure what happened even with this basic example (I knew the integral couldn't be so small!). For a general integration in [0, infty), ther

Re: [R] bivariate vector numerical integration with infinite range

2010-09-21 Thread baptiste auguie
adaptIntegrate: Result f(x) is not numeric or has wrong dimension Best, baptiste On 21 September 2010 17:11, Hans W Borchers wrote: > baptiste auguie googlemail.com> writes: > >> >> Thanks, adaptIntegrate() seems perfectly suited, I'll just need to >> figure a t

Re: [R] bivariate vector numerical integration with infinite range

2010-09-21 Thread baptiste auguie
Got it, thanks! baptiste On 21 September 2010 22:38, Hans W Borchers wrote: > baptiste auguie googlemail.com> writes: > >> >> Thanks. I am having trouble getting adaptIntegrate to work with a >> multivalued integrand though, and cannot find a working example. >&g

[R] lattice centre a diverging colour scale

2010-09-23 Thread baptiste auguie
Dear list, I'm using lattice::levelplot to plot a coloured image of 3D data. The range of the z values goes from negative to positive, but is not exactly centred around 0. I would however like to map a diverging colour scale with white falling exactly at 0, and both extremes being symmetrical in t

Re: [R] boundary check

2010-09-24 Thread baptiste auguie
Hi, I remember a discussion we had on this list a few months ago for a better way to decide if a point is inside a convex hull. It eventually lead to a R function in this post, http://tolstoy.newcastle.edu.au/R/e8/help/09/12/8784.html I don't know if it was included in the geometry package in th

Re: [R] Facets in ggplot2

2010-10-01 Thread baptiste auguie
Try this, qplot(outcome, counts, data=d.AD, facets=.~ treatment) HTH, 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 c

Re: [R] Include externally generated pdf in output (without Sweave)

2010-10-03 Thread baptiste auguie
Hi, Check the grImport package (I think it has a vignette, perhaps on Paul Murrell's homepage.) HTH, baptiste On 3 October 2010 14:52, Tal Galili wrote: > Hello Dieter, > > Looking at this thread (from 2005) > http://tolstoy.newcastle.edu.au/R/help/05/10/14320.html > It seems you can't read

Re: [R] Plot table as table

2010-10-13 Thread baptiste auguie
Hi, grid.table in gridExtra might give you some inspiration. HTH, baptiste On 13 October 2010 10:14, Joel wrote: > > It should look something like this (not at all relevant except the look) > > http://r.789695.n4.nabble.com/file/n2993297/tableR19.jpg > -- > View this message in context: > htt

Re: [R] Artifacts in filled.contour+pdf

2010-10-25 Thread baptiste auguie
Hi, As an alternative, maybe you could use lattice::panel.levelplot.raster which I think doesn't have this problem in pdf viewers. HTH, baptiste On 26 October 2010 02:30, David Winsemius wrote: > > On Oct 25, 2010, at 6:50 AM, Mario Valle wrote: > >> Dear all, >> I'm using R 2.12.0 on Windows

Re: [R] ggplot2: how to label lines?

2010-10-26 Thread baptiste auguie
Hi, Have a look at the directlabels package; it does just that for lattice and ggplot2. HTH, baptiste On 26 October 2010 08:02, Jeffrey Spies wrote: > Hi, all, > > Let's say I have some time series data--10 subjects measured 20 > times--that I plot as follows: > > library(ggplot2) > dat <- dat

Re: [R] extracting named vector from dataframe

2010-10-31 Thread baptiste auguie
Hi, I think you want ?unlist d = data.frame(x=1, y=2, z=3) v = unlist(d) is(v) [1] "numeric" "vector" HTH, baptiste On 31 October 2010 16:54, James Hirschorn wrote: > Suppose df is a dataframe with one named row of numeric observations. I want > to coerce df into a named vector. > > > > as.ve

Re: [R] Using R for Production - Discussion

2010-11-01 Thread baptiste auguie
Hi, Regarding your '10 commandments' in Q3, you may find useful tips in "the R inferno" by Pat Burns. HTH, baptiste On 2 November 2010 05:04, Santosh Srinivas wrote: > Hello Group, > > This is an open-ended question. > > Quite fascinated by the things I can do and the control I have on my > ac

Re: [R] How do I order xyplot line points?

2010-11-07 Thread baptiste auguie
Hi, try this, xyplot(Time~Chromosome|factor(Elements), data = mtx[order(mtx$Chromosome), ], ... [snipped]) HTH, baptiste On 7 November 2010 13:17, Alex Reynolds wrote: > I have the following xyplot figure: > >  http://img577.imageshack.us/img577/686/filesizeresults1200

Re: [R] [lattice] densityplot label the peak.

2010-11-10 Thread baptiste auguie
Hi, The easiest way might be the directlabels package from R-forge. Otherwise, you could write your own panel function. HTH, baptiste On 10 November 2010 23:01, Joon Yeong Kim wrote: > Hi, > > I've been trying to find a way to label the the peak or mean of a > densityplot for a while but have

Re: [R] rasterImage and coordinate conversion

2010-11-18 Thread baptiste auguie
Hi, For curiosity's sake, below is another version with ggplot2 and Grid graphics, library(pixmap) logo <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1]) library(ggExtra) # r-forge, requires gridExtra qplot(rnorm(100),rnorm(100)) + annotate("pixmap", x=-Inf, y=-Inf, picture=lo

Re: [R] how to draw manifold?

2010-11-21 Thread baptiste auguie
Hi, I'm joining in with a question -- is it possible to vary the color of the lines along z? The 'colors' argument doesn't seem to allow a vector in this situation. Thanks, baptiste On 21 November 2010 21:02, Carl Witthoft wrote: > Thanks, Dennis.   Here's an enhanced version: > >  z <- seq(

Re: [R] Is it possible to make a matrix to start at row 0?

2010-11-22 Thread baptiste auguie
Apparently He who starts from 0 needn't be called unfortunate, fortune('indexed') baptiste On 22 November 2010 20:59, Ben Bolker wrote: > Bert Gunter gene.com> writes: > >> >> Eh??? Why would you want to do that?? (R isn't C). >> >> So the simple answer is: you can't. >> >> The other answer is

Re: [R] specifying colours in a ggplot2 piechart

2010-11-23 Thread baptiste auguie
fixing the various typos in your code, this works, lat_plot() + scale_fill_manual(value=mycolours) HTH, baptiste On 23 November 2010 19:47, John Kane wrote: > Someone was asking how to do a 16 category piechart in OpenOffice Calc and it > appears that it can not be done (which we, probably, s

Re: [R] specifying colours in a ggplot2 piechart

2010-11-23 Thread baptiste auguie
e any idea why >  scale_colour_manual(value=mycolours) > does not work.  More typos on my part or am I misunderstanding what   > scale_colour_manual(value=mycolours) is supposed to do? > > Thanks > > > --- On Tue, 11/23/10, baptiste auguie wrote: > >> From: baptiste

Re: [R] apply over list of data.frames

2010-11-24 Thread baptiste auguie
Hi, Try this, do.call(`+`, x) / length(x) HTH, baptiste On 24 November 2010 20:37, Tim Howard wrote: > R users, > This probably involves a simple incantation of one of the flavors of apply... > that I can't yet figure out. Consider a list of data frames. I'd like to > apply a function (mean

Re: [R] Comparing two functions

2010-11-28 Thread baptiste auguie
Hi, Your function fails for a number of reasons. One of them is your comparison (use browser() to see what is the value taken by f in your function). Also, n, mean, min and max could not be extracted from ... with your construction. Here's my suggestion, randomIra = function(f="runif", ...){ swi

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 VeryLongWordIndee

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 little

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 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 > search > for th

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 with

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 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 vector are identi

Re: [R] Nested layout()

2010-12-17 Thread baptiste auguie
Hi, Also, see the gridbase package that gives you the flexibility of Grid viewports. HTH, baptiste On 17 December 2010 09:33, Jim Lemon wrote: > On 12/17/2010 02:00 PM, Dario Strbenac wrote: >> >> Hello, >> >> Is it possible to call a graphing function that uses layout() multiple >> times and

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 wrote: > legend("topleft", legend=c(bquote(.(txt) == .(obv)*degree), "Von Mises > distribution"

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 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 user input. I ha

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 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 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  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 wrote: > Hello R-Group, > > I am trying plott

Re: [R] Basic ggplot question

2011-01-10 Thread baptiste auguie
yers, 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 >

Re: [R] Sum list elements

2010-07-27 Thread baptiste auguie
Hi, do.call(sum, mylist) ?do.call baptiste On 27 July 2010 14:36, Nicola Sturaro Sommacal wrote: > Hi! > > I have a list of 24 elements, all of the same type (dataframe, for example). > > I am looking for an alternative to mylist[[1]] + mylist[[2]] + ... + > mylist[[24]] to obtain the sum. > >

Re: [R] hatching posibility in Panel.Polygon

2010-07-27 Thread baptiste auguie
Hi, library(gridExtra) example(patternGrob) provides some patterns to fill a rectangular area using Grid graphics. It could in theory be used in lattice. I wouldn't use it either, but I can imagine how it might be useful on very special occasions. Best, baptiste On 28 July 2010 06:11, HC

Re: [R] Output (graphics and table/text)

2010-08-05 Thread baptiste auguie
Hi, To add tables, the gplots package has a textplot() function, and for Grid graphics there is a grid.table() function in gridExtra. HTH, baptiste On 5 August 2010 00:02, Ralf B wrote: > Hi R Users, > > I need to produce a simple report consisting of some graphs and a > statistic. Here simpli

Re: [R] help to polish plot in ggplot2

2010-08-11 Thread baptiste auguie
Hi, One way you could do it is to create a separate graph for each category. The y axis labels would replace the strip labels. You could then stack the graphs on the page, and add a common legend. The tricky part would be to make sure the different panels have the same width and height. Another o

Re: [R] help to polish plot in ggplot2

2010-08-12 Thread baptiste auguie
## hack: tweak ggplot2's axis.title.y option to use our gTree foo <- function() function(label, x, y) ylab p + opts(strip.text.y =theme_blank(), strip.background=theme_blank()) + opts( axis.title.y = foo()) HTH, baptiste On 12 August 2010 07:44, baptiste auguie wrot

Re: [R] find value between two other numbers?

2010-08-12 Thread baptiste auguie
Hi, I see no need to construct the vector, try this instead, belong = function(x=4, y=c(1,10)) x <= y[2] && x >= y[1] see also ?findInterval HTH, baptiste On 13 August 2010 01:10, fishkbob wrote: > > So basically I want to do this - > > 4 %in% 1:10 > should return true > > Would there be an

[R] cacheSweave / pgfSweave driver for package vignette

2010-08-13 Thread baptiste auguie
Dear list, I wish to use a specific driver to process an sweave document in the inst/doc directory of a package. Specifically, I would like to use either cacheSweave or pgfSweave to speed up the creation of the vignette which requires lengthy computations. The same request would also apply to the

Re: [R] cacheSweave / pgfSweave driver for package vignette

2010-08-14 Thread baptiste auguie
light and, say, pgfSweave in the same document. Sincerely, baptiste On 13 August 2010 11:10, Romain Francois wrote: > > Hi, > > I've been meaning to ask the same question before. > > Le 13/08/10 11:01, baptiste auguie a écrit : >> >> Dear list, >> >&

Re: [R] grid.table and expression in table body?

2010-08-17 Thread baptiste auguie
LEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] grid      stats     graphics  grDevices utils     datasets  methods > [8] base > > other attached packages: > [1] gridExtra_0.7 > > loaded via a namespace (and not attach

Re: [R] plotmath question

2010-08-19 Thread baptiste auguie
Try this, b = 20 plot(1, ylab= bquote(italic(P) * .(b)) ) HTH, baptiste On 19 August 2010 20:02, array chip wrote: > Hi all, let me give a simple example: > > b<-20 > I would like to print ylab as "P20" where "P" is printed in Italic font. When > I > do the following: > > plot(1, ylab=expre

[R] R-level expansion of Rplot%03d.png

2010-08-21 Thread baptiste auguie
Dear list, I'm using the brew package to generate a report containing various plots. I wrote a function that creates a plot in png and pdf formats, and outputs a suitable text string to insert the file in the final document using the asciidoc syntax, <% tmp <- 1 makePlot = function(p, name=paste(

Re: [R] R-level expansion of Rplot%03d.png

2010-08-21 Thread baptiste auguie
wrote: > Not sure what you want. Plot does that automatically. It seems to use > path.expand() to make the %03d expansion. Not that path.expand() is > documented to do this, but it seem to work. > > Kees > > On Sat, 21 Aug 2010 13:04:54 +0200, baptiste auguie > wrote: > &

Re: [R] R-level expansion of Rplot%03d.png

2010-08-21 Thread baptiste auguie
27;') # function needed here > png(real.name.png) > print(p) > dev.off() > pdf(real.name.pdf) > print(p) > dev.off() > cat(noquote(paste('image:',real.name.png,',width=',width,',link=real.name.pdf) > } > > On Sat, 21 Aug 2010 14:02:04 +0200

Re: [R] R-level expansion of Rplot%03d.png

2010-08-21 Thread baptiste auguie
(I really should start using these reading glasses). >> >> My apologies >> >> On Sat, 21 Aug 2010 14:20:17 +0200, baptiste auguie >> wrote: >> >>> I dunno, it doesn't seem to do it for me, >>> >>> name = "Rplot%03d.png&q

Re: [R] graphing plots of plots

2010-08-21 Thread baptiste auguie
Hi, I think you could do it quite easily with lattice, library(lattice) latticeGrob <- function(p, ...){ grob(p=p, ..., cl="lattice") } drawDetails.lattice <- function(x, recording=FALSE){ lattice:::plot.trellis(x$p, newpage=FALSE) } plots <- replicate(4, xyplot(rnorm(10)~rnorm(10),xlab=

Re: [R] Draw a perpendicular line?

2010-08-25 Thread baptiste auguie
hi, also, make sure you have set the aspect ratio to 1:1 when plotting (asp=1). HTH, baptiste On 25 August 2010 10:20, Benno Pütz wrote: > Maybe > > perp.slope = -1/slope > abline(cy - cx*perp.slope, perp.slope) > > where cx, cy are x- and y-coordinate of C, resp., and slope the slope you > c

[R] export 4D data as povray density files

2010-08-27 Thread baptiste auguie
Dear list, I wish to visualise some 4D data as a kind of colour / translucent cloud in 3D. I haven't seen such plots in R (but perhaps I missed a feature of rgl). The easiest option I found would be to export the data in povray's df3 (density file) format and visualise it with povray. The format

Re: [R] How to plot an expression-label with variable text

2010-08-27 Thread baptiste auguie
hi, try this lab =bquote(paste("Estimated ", t[50]," from ",.(what))) HTH, baptiste On 27 August 2010 20:19, Dieter Menne wrote: > > plot.new() > lab =expression(paste("Estimated ", t[50]," from tgv")) > text(0.5,0.5,lab) > # Should look the same as above. I could not get the substitute righ

Re: [R] How to Adaptively Set Up the Coordinate Range of Multiple Graphs in One Figure

2010-08-31 Thread baptiste auguie
Hi, It's easy with ggplot2, library(ggplot2) ## create an empty plot p <- ggplot(map=aes(x,y)) ## create a dummy list of data.frames with different ranges d <- replicate(4, data.frame(x=sample(1:10,1)+rnorm(10), y=sample(1:10,1)+rnorm(10)), simplify=

Re: [R] Please explain "do.call" in this context, or critique to "stack this list faster"

2010-09-05 Thread baptiste auguie
Another way that I like is reshape::melt.list() because it keeps track of the name of the original data.frames, l = replicate(1e4, data.frame(x=rnorm(100),y=rnorm(100)), simplify=FALSE) system.time(a <- rbind.fill(l)) # user system elapsed # 2.482 0.111 2.597 system.time(b <- melt(l,id=1:2)

Re: [R] Something similar to layout in lattice or ggplot

2010-09-07 Thread baptiste auguie
On 7 September 2010 17:19, Erik Iverson wrote: > See ?grid.layout or perhaps ?arrange from the gridExtra package. > gridExtra::grid.arrange(), rather. baptiste > Abhijit Dasgupta wrote: >> >> Hi, >> >> Is there a function similar to the layout function in base graphics in >> either lattice or gg

Re: [R] Something similar to layout in lattice or ggplot

2010-09-07 Thread baptiste auguie
arrange() was renamed grid.arrange() when plyr started using this name for a different function. I think it happened in version 0.6.5 of gridExtra. The current version on CRAN is 0.7. baptiste On 7 September 2010 17:46, Erik Iverson wrote: > > > baptiste auguie wrote: >> >>

Re: [R] Matrixes inside matrixes

2010-09-08 Thread baptiste auguie
Hi, You can have each cell of a matrix contain a matrix, but for a reason that is just not clear to me the matrices are wrapped in a list, m = matrix(replicate(4,matrix(1:9,3,3),simplify=FALSE), 2,2) m[1,2][[1]] str(m) and even more surprising to me, m itself has become a list for some reason.

Re: [R] large files produced from image plots?

2010-09-08 Thread baptiste auguie
Hi, I get the same crash with x11() with sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base However it works

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 mor

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 wrote

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 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 TITLE",quote=FAL

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

2011-05-08 Thread baptiste auguie
Hi, On 8 May 2011 21:18, Berwin A Turlach wrote: > G'day Dan, > > On Sun, 8 May 2011 05:06:27 -0400 > Dan Abner 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? Suggestions? Alternatively, ex

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 wrote: > > On reflection, it seems

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 wrote: > Hello, > > I would like to create a group variable that is based on the values of three > variables: > > For ex

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 wrote: > Nice to know that the `pi' can be sliced in so many different ways! > > There are exactly 3.154 x e08 seconds in a (non-leap) ye

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 wrote: > How can I cbind three or more matrice

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 wrote: > I have a dataframe df with columns x, y, and height. I want to create a

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

[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] 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] 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] 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

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

<    1   2   3   4   5   6   7   8   >