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

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

[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] curvedarrow (some graphics problem)

2009-06-25 Thread baptiste auguie
This will give you a greek character, see ?plotmath grid.text(expression(mu*"(s,t)"), 0.5, unit(5, "lines"), vp=vp2) The following works for me, it may be that you're using an outdated version of R, vp <- viewport( x = unit(0, "npc"), y = unit(0, "npc"), just = c("left", "bottom"), xscale

Re: [R] grid.polygon() + color gradient

2009-06-25 Thread baptiste auguie
Hi, I don't think the fill parameter can be a colour gradient. You'll need to create small polygons, each with its own fill (200, say). Try this, x= c(0, 0.5, 1) y= c(0.5, 1, 0.5) grid.polygon(x=x, y=y, gp=gpar(fill="grey90", col="grey90")) xx <- seq(range(x)[1],range(x)[2], length=100) yy <-

Re: [R] grid.polygon() + color gradient

2009-06-25 Thread baptiste auguie
[I neglected to check some details in the previous post] This one should work better, library(grid) x= c(0, 0.5, 1) y= c(0.5, 1, 0.5) grid.polygon(x=x, y=y, gp=gpar(fill=NA, col="grey90")) # outer shell xx <- seq(range(x)[1],range(x)[2], length=100) dx <- diff(xx) # width of clipped triangles

Re: [R] grid.polygon() + color gradient

2009-06-25 Thread baptiste auguie
at I need to append this color-gradient triangle into > a another Figure I'm working on. But when I try to do that, this wonderful > triangle overwrites the other one. Have tried to append it with not much > luck.. > Much appreciation to your help though!!! > > Kexin > >

[R] gradient fill of a grid.polygon

2009-06-26 Thread baptiste auguie
Dear list, Following a recent enquiry, I've been playing with the idea of creating a colour gradient for a polygon, using the Grid package. The idea is to draw a number of stripes of different colours, using the grid.clip function. Below is my current attempt at this, library(grid) rotate.polyg

Re: [R] changing default arguments of a function and return the modified function as a result

2009-06-26 Thread baptiste auguie
Is this what you want? myfun <- function(x, a=19, b=21){ return(a * x + b) } mysecond.fun <- function(a, b, cc=myfun, cc.args=list(a=2,b=15) ){ list(a=a, b=b, cc = function(x) cc(x, cc.args$a, cc.args$b)) } mysecond.fun(a=1,b=2)$cc(x=12) It may be that you're after a Curry (*) function, as in,

Re: [R] changing default arguments of a function and return the modified function as a result

2009-06-27 Thread baptiste auguie
see also `%but%.character` in the operators package. >rnorm %but% list( mean = 3 ) function (n, mean = 3, sd = 1) .Internal(rnorm(n, mean, sd)) baptiste [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.

[R] gradient fill of a grid.polygon

2009-06-27 Thread baptiste auguie
Following up on my previous post. I've managed to have the function return a gList rather than plot everything directly, but I get a rather obscure error message when I try to wrap the grobs in a gTree with a rotated viewport, Error in x$children[[i]] : attempt to select less than one element ho

[R] symbols duplicated in plot output

2009-06-29 Thread baptiste auguie
Dear list, I'm manually editing a large collection of pdf files that I produced with R in Adobe Illustrator. In doing so, I've had the surprise to see symbols duplicated on top each other. The following code illustrates this, pdf() plot(1, xlab=expression(mu)) dev.off() If I open this pdf in Ill

Re: [R] symbols duplicated in plot output

2009-06-30 Thread baptiste auguie
duplicated symbols #system("cat testEps.pdf",int=T) #system("cat testQuartz.pdf",int=T) #system("cat testCairo.pdf",int=T) 2009/6/30 Dieter Menne > > > > baptiste auguie-5 wrote: > > > > > > pdf() > > plot(1, xlab=expr

Re: [R] productivity tools in R?

2009-07-01 Thread baptiste auguie
2009/7/1 miguel bernal > I think there is a package to visualize the links between > functions in a package, but I don't know its name (if anybody knows it, I > will love to know it). reminds me of roxygen's callgraph (relies on graphviz), is that what you meant? baptiste [[alternativ

Re: [R] ?max (so far...)

2009-07-01 Thread baptiste auguie
For another generic approach, you might be interested in the Reduce function, rolling <- function( x, window=seq_along(x), f=max){ Reduce(f, x[window]) } x= c(1:10, 2:10, 15, 1) rolling(x) #15 rolling(x, 1:10) #10 rolling(x, 1:12) #10 Of course this is only part of the solution to the

Re: [R] exporting interactive rggobi plots

2009-07-03 Thread baptiste auguie
I've never tried it but I would have thought the package DescribeDisplay can help you, http://www.ggobi.org/describe-display/ baptiste 2009/7/3 David Winsemius > > On Jul 3, 2009, at 1:35 PM, Veerappa Chetty wrote: > > Hi , I have created a parallel coordinate plot using rrgobi. I like to >>

Re: [R] Variable names in lattice XY-plot

2009-07-03 Thread baptiste auguie
?strip.custom p <- xyplot(acet+chol+ino+acetp ~ zp, group=grp, data=data, type="l", scales=list(relation="free"), auto.key=list(title=" > > Neurotransmitters", border=TRUE)) update(p, strip=strip.custom(factor.levels=letters[1:4])) HTH, baptiste 2009/7/3 >

Re: [R] Shading the area between lines

2009-07-04 Thread baptiste auguie
Hi, You could use ?rect x = 1:5 y=1:5 plot(x,y,t="n",xaxs="i") abline(h=y) xlims = range(x) y.rect = matrix(rep(y,each=2)[-c(1, 2*length(y))], ncol=2, byrow=T) x.rect = matrix(rep(xlims), ncol=2,nrow=nrow(y.rect), byrow=T) cols = 1:4 rect(x.rect[,1], y.rect[,1], x.rect[,2], y.rect[,2],col=

Re: [R] Averaging dataframes that are stored in a list

2009-07-15 Thread baptiste auguie
Hi, you could try the reshape package, l = list(d1= data.frame(ID=letters[1:4],value=1:4), d2= data.frame(ID=letters[1:4],value= -c(1:4))) library(reshape) m = melt(l) cast(m, .~ID, fun=mean) HTH, baptiste 2009/7/15 Mark Na > Dear R-helpers, > I have a list containing 5000 elemen

Re: [R] duplicate data points on a line graph

2009-07-15 Thread baptiste auguie
Alternatively, you could make use of transparency (on some devices), or use ggplot2 to map the number of observations to the point size, d = read.table(textConnection(" x y 1 10 1 10 2 3 4 5 9 8 "),head=T) library(ggplot2) # transparency qplot(x, y, data=d, al

Re: [R] R: extract data.frames from a list

2009-07-17 Thread baptiste auguie
try this, do.call(rbind, tmp) baptiste 2009/7/17 Angel Spassov > Dear useRs and developeRs, > > I am struggling with a simple but not obviously solvable issue. Suppose I > have the following list of data.frames called 'tmp': > > a <- data.frame(a=rnorm(10),b=letters[1:10]) > (tmp <- list(a,a[1

Re: [R] legend title in qplot

2009-07-21 Thread baptiste auguie
?scale_fill_discrete() qplot(x,y,data=data.frame(x=1,y=1,f="a"),fill=f) + scale_fill_discrete("test") baptiste HTH, 2009/7/21 rajesh j > Hi, > > I've used the following command in qplot > qplot(a$V1,geom="histogram",binwidth=0.15,fill = > factor(a$V2),ylab="Frequency",xlab="Rate"); > but the

Re: [R] Question on qplot

2009-07-22 Thread baptiste auguie
try this, library(ggplot2) ggplot() + geom_histogram(aes(x=rnorm(100), fill=..count..))+ xlab(NULL)+ scale_y_continuous("")+ opts(legend.position="none") HTH, baptiste 2009/7/22 RON70 > > I have following code on "qplot" : > > library(ggplot2) > ggplot() + geom_histogram(aes(x=rnorm(100), fi

Re: [R] graphs

2009-07-25 Thread baptiste auguie
Try with ?segments, x<-seq(75,225,0.1) plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy') #abline(v = 149, col = "black") segments(149, 0, 149, dnorm(149,140,15)) curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE) HTH, baptiste 2009/7/26 Mary A. Marion > Hello, > >

Re: [R] Adding picture to graph?

2009-07-29 Thread baptiste auguie
several options are listed here: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:display-images baptiste > > Rainer M Krug schrieb: >> >> Hi >> >> while teaching R, the question came up if it would be possible to add >> a picture (saved on the HDD) to a graph (generated by plot()

Re: [R] Looping through R objects with $ operator and tags

2009-07-30 Thread baptiste auguie
essentially the same, object1 = object2 = object3 = data.frame(Distance = 1:10) foo = function(o){ within(get(o), LogDist <- log10(Distance)) } my.objects = paste("object", 1:3,sep="") lapply(my.objects, foo) It is however advisable to group the initial objects

Re: [R] lattice shingle plot axis annotation

2009-07-30 Thread baptiste auguie
Hi, Chapter 8 of the lattice book has some examples (you can see the code and figures on r-forge). Perhaps you could try something like this, d = data.frame(x=1:10,y=1:10,f=sample(letters[1:2],10,repl=T)) axis.custom = function(side, ...){ if(side == "bottom") switch(pa

Re: [R] Scatter Plot

2009-07-30 Thread baptiste auguie
Hi, Try this, plot(1:5,1:5, t='p', pch=paste(1:5)) baptiste 2009/7/30 amna khan : > Dear Sir > > I want to write the numbers 1,2,3,on a scatter plot instead of points, > like 1 corresponding to first point on plot, 2 corresponding second point > etc. > Help in this regard. > > Regards > >

Re: [R] for loop for file names

2009-07-30 Thread baptiste auguie
Try this, files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="") lapply(files, load) HTH, baptiste 2009/7/30 waltzmiester : > > I am trying to load binary files in the following fashion > > load("pred/Pred_pres_a_indpdt") > load("pred/Pred_pres_b_indpdt") > load("pred/Pred_pres_c_ind

Re: [R] Scatter Plot

2009-07-31 Thread baptiste auguie
to 9 remaining points were > marked by 1. I want to have numbers 1 to 22 instead of points on scatter > plot. > Suggest more. > Kind Regards > On Thu, Jul 30, 2009 at 11:57 PM, baptiste auguie > wrote: >> >> Hi, >> >> Try this, >> >> plot(1:5,1:5

Re: [R] xyplot with 2 panels and 2 different x-scales

2009-07-31 Thread baptiste auguie
Hi, you want only the x scale to be free, xyplot(place~rank|type, data=df1, panel= function(x, y, ..., subscripts) { panel.xyplot(x,y,..., subscripts) require(grid) panel.grid(h = -1,v = 0, lty="dotted") grid.text(unit(x,"native"),

Re: [R] re moving intial numerals

2009-08-01 Thread baptiste auguie
Try this, formatC(d %% 1e5, width=5, flag = "0", mode="integer") [1] "00735" "02019" "04131" "04217" "04629" "04822" "10115" "11605" "14477" [10] "15314" "15438" "19040" "19603" "22735" "22853" "23415" "24227" "24423" HTH, baptiste 2009/7/31 PDXRugger : > > > I would like to recreate "data"

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

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] 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] 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] 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] 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-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] 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] 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] 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] 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] 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] 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] 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] superimposing xyplots on same scale

2009-09-24 Thread baptiste auguie
Hi, try ?as.layer in the latticeExtra package. HTH, baptiste 2009/9/24 Larry White : > I have two xyplots that i want to superimpose (code below).  By default they > are displayed on slightly different y scales (one runs from 10 to 25, the > other from 10 to 30). I would like to force them both

Re: [R] how to make a function recognize the name of an object/vector given as argument

2009-09-24 Thread baptiste auguie
Try this, testFun <- function(x,y) plot(x,y, main=paste("plot of",deparse(substitute(x)),"and", deparse(substitute(y))) ) a1 <- 5:8 b1 <- 9:6 testFun(a1,b1) ?deparse HTH, baptiste 2009/9/24 Wolfgang Raffelsberger : > Dear guRus, > I'd like to learn how to make a function recognize the name

Re: [R] Color of the plot which correspond to the group of the observations

2009-09-24 Thread baptiste auguie
Try these three options, dp <- c(1,4,3,2,5,7,9,8,9,2) tp <- 1:10 group <- factor(c(1, 2, 1, 2, 1, 3, 1, 3, 3, 2), label=letters[1:3]) plot(tp,dp, type= 'p', col = group) d <- data.frame(dp=dp, tp=tp, group=group) library(lattice) xyplot(dp~tp, data=d, groups=group, auto.key=TRUE) library(

Re: [R] graphics mailing list?

2009-09-25 Thread baptiste auguie
OK, it makes sense. Let's try that. Best, baptiste 2009/9/25 Paul Murrell : > Hi > > > baptiste.auguie wrote: >> >> (Sorry about the double post earlier, googlemail is having hiccups today) >> >> 2009/9/24 Romain Francois : >>> >>> Why just grid ? why not a list for all kind of graphics ? >> >>

Re: [R] superimposing xyplots on same scale

2009-09-25 Thread baptiste auguie
2009/9/25 Felix Andrews : > Sorry, doubleYScale is not appropriate, since you specifically want a > common y scale. > > I think Baptiste was suggesting to use layer(), rather than > as.layer(): Truth be told, I wasn't quite sure what the initial request meant. I took it quite literally, as "superi

Re: [R] packGrob and dynamic resizing

2009-09-25 Thread baptiste auguie
126.733 2.414 135.450 grid.newpage() system.time(table2(content)) # user system elapsed # 22.387 0.508 24.457 grid.newpage() system.time(table3(content)) # user system elapsed # 4.868 0.124 5.695 dev.off() ### code ends ### #system("open test-layout.pdf")

Re: [R] summarize-plyr package

2009-09-25 Thread baptiste auguie
Hi, it works for me with plyr version 0.1.9. Try upgrading to the latest version, or post your sessionInfo() HTH, baptiste 2009/9/25 Veerappa Chetty : > Hi,I am using the amazing package 'plyr". I have one problem. I would > appreciate help to fix the following error: Thanks. > ___

Re: [R] packGrob and dynamic resizing

2009-09-26 Thread baptiste auguie
Hi, I just tried a fourth variant, closer to what ggplot2 uses (I think): to each grob is assigned a viewport with row and column positions (in my example during their construction, with ggplot2 upon editing), and they're all plotted in a given grid.layout. The timing is poor compared to pushing a

Re: [R] Mixed font in lattice xyplot lables

2009-09-26 Thread baptiste auguie
Hi, I think you are feeding two expressions to xlab instead of one. Try this instead, xyplot(y ~ x, dat,xlab=expression("Moran's " * italic(I))) HTH, baptiste 2009/9/26 Andrewjohnclose : > > Hi all, can anyone suggest a reason as mto why my xlab is plotting this text > at oposite ends of axi

Re: [R] Re ading Functions that are in a Vector

2009-09-28 Thread baptiste auguie
Hi, You said, >sumstats <- c(mean,sd) >sumstats[1] >#Gives this error but this is not an error! You created a list that contains two functions, and sumstats[1] simply prints the first one. HTH, baptiste __ R-help@r-project.org mailing list https://s

[R] dichromat, regexp, and grid objects

2009-09-28 Thread baptiste auguie
Dear list, The dichromat package defines a dichromat function which "Collapses red-green color distinctions to approximate the effect of the two common forms of red-green colour blindness, protanopia and deuteranopia." library(dichromat) library(grid) colorStrip <- function (colors = 1:3, draw

Re: [R] Scaling data

2009-09-28 Thread baptiste auguie
Try this, library(ggplot2) apply(matrix(10*rnorm(10),2), 1, ggplot2::rescale) HTH, baptiste 2009/9/28 Dry, Jonathan R : > Hello all > > I have a data frame representing a matrix of data.  For each of my variables > (rows) I want to scale the data between 0 (representing the minimum value in

Re: [R] Re ading Functions that are in a Vector

2009-09-28 Thread baptiste auguie
Also, have a look at each() in the plyr package, library(plyr) each(length, mean, var)(rnorm(100)) baptiste 2009/9/28 trumpetsaz : > > I am trying to write a function that will have an input of a vector of > functions. Here is a simplistic example. > sumstats <- c(mean,sd) > sumstats[1] > #Give

Re: [R] Determining name of calling function.

2009-09-28 Thread baptiste auguie
Not answering your question, but just pointing out the example of base::.NotYetImplemented() essentially doing the same thing. Best, baptiste 2009/9/28 Rolf Turner : > > I have vague recollections of seeing this question discussed on r-help > previously, but I can't find the relevant postings

Re: [R] overwritten plots in pdf file

2009-09-29 Thread baptiste auguie
Hi, Try opening and closing the device outside the loop, pdf("D:/research/plot.pdf") for (i in 1:n) { plot(mon, mu, type ='o') } dev.off() HTH, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do re

Re: [R] Macro variable substitution

2009-09-29 Thread baptiste auguie
Hi, I guess you want ?assign See also this page for a working example, http://wiki.r-project.org/rwiki/doku.php?id=guides:assigning-variable-names HTH, baptiste 2009/9/29 David Young : > Hello All, > > I'm a new R user and have a question about what in SAS would be called > macro variable sub

Re: [R] lattice: How to display no box but only a y-axis on the left + Thicker lines

2009-09-30 Thread baptiste auguie
2009/9/30 lith : >> Yes. You can get back the tick marks with scaless$col: > > Thanks for the hint. May I kindly ask what would be the easiest way to > draw a line on the left side? Try this, mpanel = function(...) { grid.segments(0,0,0,1) ; panel.bwplot(...) } bwplot(y~x, data=data.frame(y=rnor

Re: [R] dichromat, regexp, and grid objects

2009-09-30 Thread baptiste auguie
code for colour and fill regular expressions... baptiste 2009/9/28 baptiste auguie : > Dear list, > > The dichromat package defines a dichromat function which "Collapses > red-green color distinctions to approximate the effect of the two > common forms of red-green colour b

Re: [R] A point in a vector?

2009-09-30 Thread baptiste auguie
Hi, assuming v is sorted, try this, v[ findInterval(x,v)+0:1 ] see ?findInterval and perhaps ?cut HTH, baptiste 2009/9/30 Corrado : > Dear list, > > I have a strange requirement I have a vector, for example v<- > c(0,0,0,0,1,2,4,6,8,8,8,8). I have a value,for example x<- 4.8. > > I wou

[R] pass "..." to multiple sub-functions

2009-10-01 Thread baptiste auguie
Dear list, I know I have seen this discussed before but I haven't been successful in searching for "ellipsis", "dots", "..." in the archives. I would like to filter "..." arguments according to their name, and dispatch them to two sub-functions, say fun1 and fun2. I looked at lm() but it seemed mo

Re: [R] pass "..." to multiple sub-functions

2009-10-01 Thread baptiste auguie
2009/10/1 Peter Ruckdeschel : > > removed <- c("lty",params.fun1) > ## I assume you do not want to pass on argument "lty"... > dots.remaining <- cl[-1] ### remove the function name > dots.remaining <- dots.remaining[! names(dots.remaining) > %in% removed] > > Be

Re: [R] Looking for a better way to document my packages

2009-10-01 Thread baptiste auguie
Hi, I know of three options that resemble your query, - the roxygen package - a ruby script called weeder by Hadley Wikham - the inlinedocs package on r-forge I only ever used roxygen though, so i can't speak for the relative merits of the others. HTH, baptiste 2009/10/1 Steve Lianoglou :

[R] inverse currying

2009-10-01 Thread baptiste auguie
Dear list, I have the following function, sugar = function(fun, id = "id"){ ff <- formals(fun) if( id %in% names(ff)) stop("id is part of args(fun)") formals(fun) <- c(unlist(ff), alist(id=)) fun } which one may use on a function foo, foo = function(x){ x } sugar(foo) # results i

Re: [R] plot ᵒ C in graph axis label

2009-10-01 Thread baptiste auguie
Hi, You cannot start with a "*" in expression(). Try this, plot(x~y,ylab=expression(~degree~C)) or even, as a short-cut, plot(x~y,ylab=~degree~C) HTH, baptiste 2009/10/2 e-letter : > Readers, > > I have tried to use a plotmath command to add the temperature degree > sign (i.e. ᵒ C) to the

Re: [R] plot scale

2009-10-02 Thread baptiste auguie
Hi, It looks like lattice or ggplot2 might make this easier, but I'm not entirely sure I understood the problem, short of an example. Best, baptiste 2009/10/2 Duncan Murdoch : > On 02/10/2009 4:07 AM, Ben Kenward wrote: >> >> Hi, >> >> Is there a way to set the scale of a plot (i.e. number of a

Re: [R] plot subscript text and percentage symbol in graph label axis

2009-10-02 Thread baptiste auguie
try this, plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~"%")) baptiste 2009/10/2 e-letter : > Readers, > > I am unable to plot a label consisting of both subscript text and > percentage (%) symbol: > > x<-(1:10) > y<-(200:191) > plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2

Re: [R] inverse currying

2009-10-02 Thread baptiste auguie
::as.alist.symbol(id) formals(fun) <- c(unlist(ff), new.arg) fun } foo = function(x, a=1){ x } sugar(foo) sugar(foo, 'a') sugar(sugar(foo)) sugar(foo, 'my.new.arg') Best, baptiste 2009/10/1 baptiste auguie : > Dear list, > > I have the following function,

Re: [R] add lines() to 1st plot in layout() after calling 2nd plot()?

2009-10-04 Thread baptiste auguie
Hi, Try this, dev.new() layout(matrix(1:4,2, by=T)) plot(1:10,main="top left plot") plot(1:10,main="top right plot") plot(1:10,main="bottom left plot") plot(1:10,main="bottom right plot") for (ii in 1:2){ for (jj in 1:2){ par(mfg=c(ii,jj)) text(5,2, lab=paste("plot #:",ii,",",jj,sep="")) } } pa

Re: [R] add lines() to 1st plot in layout() after calling 2nd plot()?

2009-10-04 Thread baptiste auguie
portant incompatibility in complicated layouts, but it seems to work at least for simple ones. Best regards, baptiste 2009/10/4 baptiste auguie : > Hi, > > Try this, > > dev.new() > layout(matrix(1:4,2, by=T)) > > plot(1:10,main="top left plot") > plot(

Re: [R] ggplot2: proper use of facet_grid inside a function

2009-10-05 Thread baptiste auguie
Hi, Whether or not what follows is to be recommended I don't know, but it seems to work, p <- ggplot(diamonds, aes(carat, ..density..)) + geom_histogram(binwidth = 0.2) x = quote(cut) facets = facet_grid(as.formula(bquote(.~.(x p + facets HTH, baptiste 2009/10/5 Bryan Hanson : > Thanks

Re: [R] ggplot2: proper use of facet_grid inside a function

2009-10-05 Thread baptiste auguie
Now why do I always come up with a twisted bquote() where a simple paste() would do! Thanks, baptiste 2009/10/5 hadley wickham : >> Whether or not what follows is to be recommended I don't know, but it >> seems to work, >> >> p <- ggplot(diamonds, aes(carat, ..density..)) + >>  geom_histogram(b

Re: [R] italics help in plot

2009-10-06 Thread baptiste auguie
Hi, Try this, > x= "my title" > plot(1,1, main = bquote(italic(.(x HTH, baptiste 2009/10/6 Jacob Kasper : > Part of my script reads: > > speciesName <- names(data)[i] > plot(year,depth, xlab="Year", > ylab="Depth(m)",main=expression(italic(paste(speciesName))) ) > > Unfortunately, this jus

Re: [R] ggplot2: mapping categorical variable to color aesthetic with faceting

2009-10-06 Thread baptiste auguie
Hi, I may be missing an important design decision, but could you not have only a single data.frame as an argument of your function? From your example, it seems that the colour can be mapped to the fac1 variable of "data", compareCats <- function(data) { require(ggplot2) p <- ggplot(data, a

Re: [R] ggplot2: mapping categorical variable to color aesthetic with faceting

2009-10-06 Thread baptiste auguie
t;lrg", "lrg", "sm", "sm"), 25))) compareCats(data = test) rem <- sample(10, 1:ncol(test)) # randomly remove a few points here and there last_plot() %+% test[-rem, ] # replot with new dataset HTH, baptiste 2009/10/6 baptiste auguie : > Hi, > &

Re: [R] ggplot equivalent of par(xaxt)

2009-10-06 Thread baptiste auguie
Hi, 2009/10/6 John Kane : > How do I suppress the numbers on the x-axis? > Try this, p + opts(axis.text.x = theme_blank()) HTH, baptiste > Thanks > > >      __ > [[elided Yahoo spam]] > > ___

Re: [R] ggplot equivalent of par(xaxt)

2009-10-06 Thread baptiste auguie
Thanks very much. > > > > --- On Tue, 10/6/09, baptiste auguie wrote: > >> From: baptiste auguie >> Subject: Re: [R] ggplot equivalent of par(xaxt) >> To: "John Kane" >> Cc: "R R-help" >> Received: Tuesday, October 6, 2009, 2:57 PM &

Re: [R] two plots on the same axis

2009-10-07 Thread baptiste auguie
Hi, Your two data sets have a different year so I'm not sure what you want to do with the x axis. The code below plots both data sets on the same graph, with a range of two years, d1 <- read.table("~/Downloads/2005.txt") d2 <- read.table("~/Downloads/2006.txt") cleanup <- function(d){ names

Re: [R] Slope between two points

2009-10-08 Thread baptiste auguie
Hi, Like this perhaps? > slope = diff(y) / diff(x) > str(slope) num [1:499] 1.5068 -1.8406 2.1745 0.0676 -2.6088 ... HTH, baptiste 2009/10/8 FMH : > Dear All, > > Let  499 piece-wise lines were buit up by 500 pair of observations, via R > code below. > > x <- 1:500 > y <- rnorm(500) > plot(x

Re: [R] xyplot#strips like ggplot?

2009-10-08 Thread baptiste auguie
Hi, Try the useOuterStrips function in the latticeExtra package. HTH, baptiste 2009/10/8 Christian Ritter : > Dear all, > > I want to split the strips in xyplot and push them into the margins ... > > Tried to find this in common documentation (such as Deepayan's book) on > lattice ... but so f

[R] proto and get()

2009-10-08 Thread baptiste auguie
Dear all, In mucking around with ggplot2, I've hit the following snag, library(ggplot2) # this returns a grob, OK GeomAbline$icon() # lines[GRID.lines.9] # this returns the function icon, OK GeomAbline$icon # proto method (instantiated with ): function (.) # linesGrob(c(0, 1), c(0.2, 0.8)) #

Re: [R] proto and get()

2009-10-08 Thread baptiste auguie
... without answering my previous question, I have just found a fortune-hate workaround, getIcon <- function(geom){ st <- paste("Geom", firstUpper(geom),"$icon", sep="") eval(parse(text=st)) } getIcon("abline") I'm still curious about the get() behaviour though. Best, baptiste __

Re: [R] external variable by inside-function routines modifications

2009-10-08 Thread baptiste auguie
Hi, with assign, foo <- function(var){ assign("var", var+1, envir = .GlobalEnv) } var =1 foo(2) var # [1] 3 HTH, baptiste 2009/10/8 devol : > > Dear all, > >  could you please advice whether it is possible somehow to modify an > external (from the point of some function view) variable by

Re: [R] field names as function parameters

2009-10-11 Thread baptiste auguie
Hi, I think this is a case where you should use the ?"[[" extraction operator rather than "$", d = data.frame(a=1:3) mytarget = "a" d[[mytarget]] HTH, baptiste 2009/10/11 tdm : > > Hi, > > I am passing a data frame and field name to a function. I've figured out how > I can create the formula

Re: [R] Manipulating Arrays

2009-10-11 Thread baptiste auguie
Hi, the abind package can help you with the first query, ## add values library(abind) arr <- abind(arr,arr[1,,,] * 2 + 1,along=1) dim(arr) as for the second, maybe you can use negative indexing, ## remove values arr <- arr[-2,,,] HTH, baptiste 2009/10/11 ampc : > > Manipulating Arrays > Usin

Re: [R] add lines() to 1st plot in layout() after calling 2nd plot()?

2009-10-12 Thread baptiste auguie
rom: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of baptiste auguie >> Sent: Sunday, October 04, 2009 3:33 AM >> To: r-help >> Subject: Re: [R] add lines() to 1st plot in layout() after calling 2nd >> plot()? >> >> Hi, >>

Re: [R] Scatter plot using icons (from a gif) instaed of points - is it possible ?

2009-10-14 Thread baptiste auguie
Hi, You'll probably find that there are two parts to your query: 1- import a bitmap into R, for this I'd suggest the wiki page, http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:display-images 2- place the image (now some sort of matrix of colour points) at different locations on a

Re: [R] Code improvement

2009-10-22 Thread baptiste auguie
Hi, I don't know if it helps, but looking at the output of xyplot you can extract the legend (a grid.frame) as follows, library(grid) library(lattice) p = xyplot(x~y, group=x,data=data.frame(x=1:10,y=1:10), auto.key=list(space="right")) legend = with(p$legend$right, do.call(lattice:::drawSimpleK

[R] regular expressions

2009-10-26 Thread baptiste auguie
Dear list, I have the following text to parse (originating from readLines as some lines have unequal size), st = c("START text1 1 text2 2.3", "whatever intermediate text", "START text1 23.4 text2 3.1415") from which I'd like to extract the lines starting with "START", and group the subsequent fi

Re: [R] regular expressions

2009-10-26 Thread baptiste auguie
fy = rbind) >> s >     text1  text2    text3 > [1,] "1"    "2.3"    "5" > [2,] "23.4" "3.1415" "6" > > If there are non-START fields that do match pat then grep out the > START fields first. > > On Mon,

Re: [R] reset par() within plot layout

2009-10-27 Thread baptiste auguie
Hi, >From ?par, "Value When parameters are set, their former values are returned in an invisible named list." Therefore opar <- par(col="red") will not contain col="red". HTH, baptiste 2009/10/27 Janke ten Holt : > This seems to work indeed. But I don't understand why... I would think > tha

Re: [R] Why I get this error? Error in close.connection(f) : invalid connection

2009-10-27 Thread baptiste auguie
Hi, >From ?read.csv "Alternatively, file can be a readable text-mode connection (which will be opened for reading if necessary, and if so closed (and hence destroyed) at the end of the function call)" HTH, baptiste 2009/10/27 Peng Yu : > I don't understand why I can not close 'f'. This may b

Re: [R] read.table but more tables at once

2009-10-28 Thread baptiste auguie
Hi, Try this, files <- paste("RA94010",1:3,sep="") # or files <- list.files(pattern = "RA94010") list.of.data <- lapply(files, read.table, header=F) # if required, collapse into a single data.frame do.call(rbind, list.of.data) HTH, baptiste 2009/10/28 Sybille Wendel : > Dear all, > > I have

<    1   2   3   4   5   6   7   8   >