Re: [R] Greek symbols on ylab= using barchart() {Lattice}

2009-12-09 Thread baptiste auguie
and (mu*g/m^3). Thanks again, Peng Cai On Wed, Dec 9, 2009 at 12:02 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, try this, barchart(1:2, ylab=expression(mu*g/m^3)) ?plotmath baptiste 2009/12/9 Peng Cai pengcaimaill...@gmail.com:   Hi All, I'm trying to write ug/m3

Re: [R] A GGPLOT ploting question

2009-12-07 Thread baptiste auguie
Hi, I think you have two options: 1- use a specific formatter in scale_x_continuous, e.g. last_plot + scale_x_continuous(formatter=percent) 2- specify breaks and labels, last_plot + scale_x_continuous(breaks=c(2,6), labels=paste(c(2,6),%)) HTH, baptiste 2009/12/7 Megh

Re: [R] outputting functions in lapply

2009-12-07 Thread baptiste auguie
Hi, I was about to send the exact same answer as you just received, so I'll add a note instead. Your problem looks a bit like Currying, Curry - # original from roxygen function (f, ..., .left=TRUE) { .orig = list(...) function(...){ if(.left) {args - c(.orig, list(...))} else

Re: [R] How to apply five lines of code to ten dataframes?

2009-12-07 Thread baptiste auguie
Hi, You could define a function that does the calculations for a given data.frame and apply it to all your data.frames, d1 - data.frame(a=1:10, b=rnorm(10)) d2 - data.frame(a=-(1:10), b=rnorm(10)) calculations - function(d){ if(is.character(d)) d - get(d) transform(d, c =

Re: [R] Referencing variable names rather than column numbers

2009-12-05 Thread baptiste auguie
Hi, Try this, cor(pollute[ ,c(Pollution,Temp,Industry)]) and ?[ in particular, Character vectors will be matched to the names of the object HTH, baptiste 2009/12/5 John-Paul Ferguson ferguson_john-p...@gsb.stanford.edu: I apologize for how basic a question this is. I am a Stata user who

Re: [R] multidimensional point.in.polygon??

2009-12-04 Thread baptiste auguie
came across a thread in which baptiste auguie said one general way to do this would be to compute the convex hull (?chull) of the augmented set of points and test if the point belongs to it; an approach I'd considered generalising to multiple points thus (pseudo R code

Re: [R] Apparent different in symbol scaling between xyplot and grid.points

2009-12-04 Thread baptiste auguie
Hi, I think the size mismatch occurs because of a different default for the fontsize (and grid.points has a size of 1 character by default). Compare the following two examples, # default grid.newpage() pushViewport(viewport(x=unit(0.5, npc), y=unit(0.5, npc)))

Re: [R] User's function

2009-12-04 Thread baptiste auguie
Hi, try ?do.call do.call(cbind, replicate(3, 1:10, simplify=FALSE)) HTH, baptiste 2009/12/4 Lisa lisa...@gmail.com: Hello, All, I want to write a function to do some works based on the arguments. For example, bind some variables (arguments) as this: myfunction - function(arg1, arg2,

Re: [R] adding bmp/jpg/gif to an existing plot

2009-12-04 Thread baptiste auguie
Hi, If you can first convert the image to ppm format, the pixmap package has an addlogo function that can do just what you want, x - read.pnm(system.file(pictures/logo.ppm, package=pixmap)[1]) plot(1:10,1:10) addlogo(x, px=c(2, 4), py=c(6, 8), asp=1) One could probably get inspiration from the

Re: [R] subset or condition as argument to a function

2009-12-01 Thread baptiste auguie
Hi, an alternative to parse() is to use quote and bquote, set.seed(123) d = data.frame(a=letters[1:5], b=1:10, c=sample(0:1, 10, repl=TRUE)) cond1 - quote(a==b) cond2 - quote(b 6) cond3 - bquote(.(cond1) .(cond2)) subset(d, eval(cond1)) subset(d, eval(cond2)) subset(d, eval(cond3)) HTH,

Re: [R] ggplot legend for multiple time series

2009-12-01 Thread baptiste auguie
Hi, I don't understand why you used scale_manual_colour if you want only black lines. To have different line types in the legend you can map the linetype to the data, huron - data.frame(year=1875:1972, level=LakeHuron) ggplot(huron, aes(year)) + geom_line(aes(y=level+5, linetype=above)) +

Re: [R] Why .Diag and .asSparse are not accessible in R sessions?

2009-11-29 Thread baptiste auguie
Hi, They're not exported from the stats namespace, stats:::.Diag stats:::.asSparse ?::: HTH, baptiste 2009/11/29 Peng Yu pengyu...@gmail.com: '.Diag' and '.asSparse' are defined in contrast.R. I'm wondering why I don't see them in my R session. Is it because that they start with '.'?

Re: [R] Concave hull

2009-11-27 Thread baptiste auguie
on CRAN implementing such an idea: alphahull, phull is other package, kjetil On Thu, Nov 26, 2009 at 6:11 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: 2009/11/26 Ted Harding ted.hard...@manchester.ac.uk: Raising a rather general question here. This is a tantalising discussion

Re: [R] Simple Function doesn't work?

2009-11-27 Thread baptiste auguie
Hi, The error message, Error in grid[i] - x + (i - 1) * (y - x)/m : object of type 'closure' is not subsettable indicates that grid is actually known to R as a function (type grid to see its definition). You can define your own variable with the same name, but that needs to be done before the

Re: [R] Replace Values in Matrix

2009-11-27 Thread baptiste auguie
Hi, Try this, matrizt[is.na(matrizt)] - 0 HTH, baptiste 2009/11/27 Romildo Martins romildo.mart...@gmail.com: Hello, how to replace the NA by number zero? matrizt                 [,1]           [,2]             [,3]        [,4] [1,] 1.000            NA             NA         NA

Re: [R] Does nargin and nargout work with R functions?

2009-11-26 Thread baptiste auguie
Hi, I think you can use match.call() to retrieve the number of arguments passed to a function (see below), but I don't think nargout makes sense in R like it does in Matlab. foo - function(...){ print(match.call()) nargin - length(as.list(match.call())) -1 print(nargin) } foo(a=1, b=2)

Re: [R] Concave hull

2009-11-26 Thread baptiste auguie
2009/11/26 Ted Harding ted.hard...@manchester.ac.uk: Raising a rather general question here. This is a tantalising discussion, but the notion of concave hull strikes me as extremely ill-defined! I'd like to see statement of what it is (generically) supposed to be. I'm curious too, but I can

Re: [R] lattice: plotting in a loop

2009-11-25 Thread baptiste auguie
Hi, it's a FAQ, you need to print() the plot, http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f baptiste 2009/11/25 Ryan Archer ra.list...@gmail.com: Hi, I'm having trouble seeing graphics output from lattice xyplot() when called from inside a

Re: [R] Define return values of a function

2009-11-22 Thread baptiste auguie
hi, Try making your last line invisible( list(table=xtb, elbat=btx) ) HTH, baptiste 2009/11/22 Soeren.Vogel soeren.vo...@eawag.ch: I have created a function to do something: i - factor(sample(c(A, B, C, NA), 793, rep=T, prob=c(8, 7, 5, 1))) k - factor(sample(c(X, Y, Z, NA), 793, rep=T,

Re: [R] How to make a matrix of a number of factors?

2009-11-22 Thread baptiste auguie
Hi, Try this, do.call(expand.grid, lapply(7:3, seq, from=1)) HTH, baptiste 2009/11/22 Peng Yu pengyu...@gmail.com: I use the following code to generate a matrix of factors. I'm wondering if there is a way to make it more general so that I can have any number of factors (not necessarily

Re: [R] How to concatenate expressions

2009-11-20 Thread baptiste auguie
Hi, You can try this, though I hope to learn of a better way to do it, a = c(quote(alpha),quote(beta),quote(gamma)) b = lapply(1:3, function(x) as.character(x)) c = c(quote('-10'^th), quote('-20'^th), quote('-30'^th)) testplot - function(a,b,c) { text - lapply(seq_along(a),

Re: [R] name of a name

2009-11-19 Thread baptiste auguie
Hi, Try this, d - data.frame(a=1:4, b=3:6) var - a mean(d[var]) ## or, if you are not aware of ## fortune(parse) xx - paste(d$,var, sep=) mean(eval(parse(text=xx))) HTH, baptiste 2009/11/19 William Simpson william.a.simp...@gmail.com: I have quite a complicated problem that's hard to

Re: [R] ddply function nesting problems

2009-11-19 Thread baptiste auguie
Hi, I think your ddply call with a calculation inside .( ) is the problem. Are you sure you need to do this? Performing the cut outside ddply seems to work fine, determine_counts-function() { min_range-1 max_range-30 bin_range_size-5 Me_df-data.frame(Data =

Re: [R] Lattice plot

2009-11-18 Thread baptiste auguie
  1     35   70  3.0        y 5   1    120  140 -1.3        n 6   1    180  190  0.2        y ## Code courtesy of BAPTISTE AUGUIE library(ggplot2) ggplot(data=x2) +  geom_segment(aes(x=start1, xend=end1, y=meth, yend=meth)) - Can I get lattice to do a similar graph for the panels? thanks

[R] parsing numeric values

2009-11-18 Thread baptiste auguie
Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax =1.3770E-03 bx =3.4644E-07 ay =1.9412E-04 by =4.8840E-08 other text aax =

Re: [R] parsing numeric values

2009-11-18 Thread baptiste auguie
expression not needed On Wed, Nov 18, 2009 at 7:28 AM, Henrique Dallazuanna www...@gmail.com wrote: Try this: strapply(input, ([0-9]+\\.[0-9]+E-[0-9]+), c, simplify = rbind, combine = as.numeric) On Wed, Nov 18, 2009 at 9:57 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear

Re: [R] parsing numeric values

2009-11-18 Thread baptiste auguie
haven't checked it carefully and would appreciate folks pointing out where it trips up (e.g. perhaps with NA's). Best, Bert Gunter Genentech Nonclinical Biostatistics  -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of baptiste

Re: [R] parsing numeric values

2009-11-18 Thread baptiste auguie
3.4644e-07 2 0.00019412 4.8840e-08 3 0.00137700 3.4644e-07 4 0.00019412 4.8840e-08 On Wed, Nov 18, 2009 at 1:54 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Thanks for the alternative approach. However, I should have made my example more complete in that other lines may

Re: [R] CM Fonts in PDF output

2009-11-17 Thread baptiste auguie
Hi, Not answering your question, but the tikzDevice package is another option if you want to match LaTeX fonts seamlessly. HTH, baptiste 2009/11/17 Markus Jochmann markus.jochm...@strath.ac.uk: Hi! On Linux I try to produce pdf graphs with computer modern fonts so that they look nice in

Re: [R] Discontinuous graph

2009-11-16 Thread baptiste auguie
Hi, An alternative with ggplot2, library(ggplot2) ggplot(data=coords) + geom_segment(aes(x=a, xend=b, y=c, yend=c)) HTH, baptiste 2009/11/16 David Winsemius dwinsem...@comcast.net: On Nov 16, 2009, at 12:40 PM, Tim Smith wrote: Hi, I wanted to make a graph with the following table (2

Re: [R] printing a single row, but dont know which row to print

2009-11-16 Thread baptiste auguie
Hi, Try this, set.seed(2) # reproducible d = matrix(sample(1:20,20), 4, 5) d d[ d[ ,2] == 18 , ] You may need to test with all.equal if your values are subject to rounding errors. HTH, baptiste 2009/11/16 frenchcr frenc...@btinternet.com: I have 20 columns of data, and in column 5 I have

Re: [R] in excel i can sort my dataset, what do i use in R

2009-11-16 Thread baptiste auguie
?order ?sort 2009/11/16 frenchcr frenc...@btinternet.com: In excel a handy tool is the sort data by column ...i.e. i can highlight the whole dataset and sort it according to a particular column...like sort the data in a column in acending or decending order where all the other columns

Re: [R] extracting the last row of each group in a data frame

2009-11-16 Thread baptiste auguie
Hi, You could try plyr, library(plyr) ddply(d,.(Name), tail,1) Name Value 1A 3 2B 8 3C 2 4D 3 HTH, baptiste 2009/11/16 Hao Cen h...@andrew.cmu.edu: Hi, I would like to extract the last row of each group in a data frame. The data frame is as follows

[R] drop unused levels in subset.data.frame

2009-11-10 Thread baptiste auguie
Dear list, subset has a 'drop' argument that I had often mistaken for the one in [.factor which removes unused levels. Clearly it doesn't work that way, as shown below, d - data.frame(x = factor(letters[1:15]), y = factor(LETTERS[1:3])) s - subset(d, y==A, drop=TRUE) str(s) 'data.frame': 5

Re: [R] drop unused levels in subset.data.frame

2009-11-10 Thread baptiste auguie
, at 9:49 AM, baptiste auguie wrote: Dear list, subset has a 'drop' argument that I had often mistaken for the one in [.factor which removes unused levels. Clearly it doesn't work that way, as shown below, d - data.frame(x = factor(letters[1:15]), y = factor(LETTERS[1:3])) s - subset(d, y

Re: [R] All possible combinations of functions within a function

2009-11-10 Thread baptiste auguie
Hi, From what I understand of your code, you might find the following construct useful, funs - c(mean, sum, sd, diff) x - 1:10 lapply(funs, do.call, args=list(x)) and then working with lists rather than naming every object individually. You might find mapply useful too when you have to pass

Re: [R] Find the first values in vector

2009-11-09 Thread baptiste auguie
Hi, One way would be, vec[ cumsum(!vec)==0 ] HTH, baptiste 2009/11/9 Grzes gregori...@gmail.com: Hi ! I have a vector: vec= TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE  TRUE  FALSE and I'm looking for a method which let me get only the first values equal TRUE from this vector.

Re: [R] Obtaining midpoints of class intervals produced by cut and table

2009-11-08 Thread baptiste auguie
Hi, Maybe something like this (inspired by ?cut), cut2num - function(f){ labs - levels(f) d - data.frame(lower = as.numeric( sub(\\((.+),.*, \\1, labs) ), upper = as.numeric( sub([^,]*,([^]]*)\\], \\1, labs) )) d$midpoints - rowMeans(d) d } a - c(1, 2, 3, 4, 5, 2, 3,

Re: [R] R and Python

2009-11-04 Thread baptiste auguie
Hi, It looks like SAGE might be another option, http://www.sagemath.org/index.html though I never tried it. HTH, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] how to display a string containing greek chrs and variables

2009-11-03 Thread baptiste auguie
Hi, try this, plot.new() x=0.8 text(0.5, 0.5, bquote(rho == .(x))) HTH, baptiste 2009/11/3 j.delashe...@ed.ac.uk: I'm trying something that I thought would be pretty simple, but it's proving quite frustrating... I want to display, for instance, the correlation coefficient rho in a

Re: [R] superscript troubles

2009-11-02 Thread baptiste auguie
Hi, Try this, x = rnorm(1) y = rnorm(1) leg = bquote(r^2*=*.(round(x,digits=3))*, P=*.(round(y, digits=3))) plot.new() legend (bty =n,topright,legend=leg) HTH, baptiste 2009/11/2 Jacob Kasper jacobkas...@gmail.com: I know that this has been revisited over and over, yet I cannot figure out

Re: [R] ggplot2: Histogram with negative values on x-axis doesn't work

2009-10-30 Thread baptiste auguie
2009/10/30 hadley wickham h.wick...@gmail.com: I read anything that mentions ggplot2 no matter where it is. ... one should hope this statement only applies to the Internet though, does it? Please do share your regexp if it's not the case. :) baptiste

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 wendel.sybi...@googlemail.com:

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 j.c.ten.h...@rug.nl: This seems to work indeed. But I don't understand why... I would

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 pengyu...@gmail.com: I don't understand why I can not close

[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 fields in

Re: [R] regular expressions

2009-10-26 Thread baptiste auguie
then grep out the START fields first. On Mon, Oct 26, 2009 at 9:30 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: 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

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,

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] add lines() to 1st plot in layout() after calling 2nd plot()?

2009-10-12 Thread baptiste auguie
- 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, 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

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 ph...@philbrierley.com: Hi, I am passing a data frame and field name to a function. I've figured out how I can create

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

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 kagba2...@yahoo.com: 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)

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 crit...@ridaco.be: 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

[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 sund...@gmail.com: Dear all,  could you please advice whether it is possible somehow to modify an external (from the point of some function view)

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(d) -

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 jacobkas...@gmail.com: Part of my script reads: speciesName - names(data)[i] plot(year,depth, xlab=Year, ylab=Depth(m),main=expression(italic(paste(speciesName))) ) Unfortunately,

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,

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

2009-10-06 Thread baptiste auguie
and there last_plot() %+% test[-rem, ] # replot with new dataset HTH, baptiste 2009/10/6 baptiste auguie baptiste.aug...@googlemail.com: 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

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

2009-10-06 Thread baptiste auguie
Hi, 2009/10/6 John Kane jrkrid...@yahoo.ca: 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
very much. --- On Tue, 10/6/09, baptiste auguie baptiste.aug...@googlemail.com wrote: From: baptiste auguie baptiste.aug...@googlemail.com Subject: Re: [R] ggplot equivalent of par(xaxt) To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Tuesday, October 6

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

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 h.wick...@gmail.com: Whether or not what follows is to be recommended I don't know, but it seems to work, p - ggplot(diamonds, aes(carat, ..density..)) +  

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=)) } } par(mfg=c(1,1))

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

2009-10-04 Thread baptiste auguie
for simple ones. Best regards, baptiste 2009/10/4 baptiste auguie baptiste.aug...@googlemail.com: 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

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

2009-10-02 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 inp...@gmail.com: Readers, I have tried to use a plotmath command to add the temperature degree sign (i.e. ᵒ

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 murd...@stats.uwo.ca: On 02/10/2009 4:07 AM, Ben Kenward wrote: Hi, Is there a way to set the scale of a plot (i.e.

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 inp...@gmail.com: Readers, I am unable to plot a label consisting of both subscript text and percentage (%) symbol: x-(1:10) y-(200:191)

Re: [R] inverse currying

2009-10-02 Thread baptiste auguie
) 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 baptiste.aug...@googlemail.com: Dear list, I have the following function, sugar = function(fun, id = id){  ff - formals(fun)  if( id

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

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

2009-10-01 Thread baptiste auguie
2009/10/1 Peter Ruckdeschel peter.ruckdesc...@web.de: 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%

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 in the

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 minil...@gmail.com: 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,

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

2009-09-30 Thread baptiste auguie
the code for colour and fill regular expressions... baptiste 2009/9/28 baptiste auguie baptiste.aug...@googlemail.com: 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

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 ct...@york.ac.uk: 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-

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: [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 dyo...@telefonica.net: Hello All, I'm a new R user and have a question about what in SAS would be called

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

[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 jonathan@astrazeneca.com: 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

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 stephaniezim...@gmail.com: 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)

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 r.tur...@auckland.ac.nz: I have vague recollections of seeing this question discussed on r-help previously, but I can't find

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

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 a.j.cl...@ncl.ac.uk: Hi all, can anyone suggest a reason as mto why my xlab is plotting this text at

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 p.murr...@auckland.ac.nz: Hi baptiste.auguie wrote: (Sorry about the double post earlier, googlemail is having hiccups today) 2009/9/24 Romain Francois romain.franc...@dbmail.com: Why just grid ? why not a list

Re: [R] superimposing xyplots on same scale

2009-09-25 Thread baptiste auguie
2009/9/25 Felix Andrews fe...@nfrac.org: 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,

Re: [R] packGrob and dynamic resizing

2009-09-25 Thread baptiste auguie
) 2009/9/25 Paul Murrell p.murr...@auckland.ac.nz: Hi baptiste auguie wrote: Dear all, I'm trying to follow an old document to use Grid frames, Creating Tables of Text Using grid Paul Murrell July 9, 2003  As a minimal example, I wrote this, gf - grid.frame(layout = grid.layout

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 chett...@gmail.com: Hi,I am using the amazing package 'plyr. I have one problem. I would appreciate help to fix the following error: Thanks.

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

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 wr...@igbmc.fr: Dear guRus, I'd like to learn how to make a function recognize

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)

Re: [R] Variable as a filename

2009-09-23 Thread baptiste auguie
Hi, The short answer would be ?paste (as in paste(year, .csv, sep=) ), but I'd suggest you try this instead, lf - list.files(pattern = .csv) lf # [1] 2003.csv 2004.csv 2005.csv ln - gsub(.csv, , lf) ln # [1] 2003 2004 2005 length(ln) lapply(lf, read.csv) ?list.files ?lapply HTH, baptiste

Re: [R] Sorting

2009-09-23 Thread baptiste auguie
yet another way, x - read.table(textConnection(Category Value + b1 + b2 + a7 + a1), header=TRUE) y = transform(x, Category = relevel(Category, c(b))) str(y) 'data.frame': 4 obs. of 2 variables: $ Category: Factor w/ 2

Re: [R] Problem in graph plotting

2009-09-23 Thread baptiste auguie
Hi, It's trivial with ggplot2, library(ggplot2) qplot(tp,dp, geom=line) + scale_y_reverse() HTH, baptiste 2009/9/23 David Winsemius dwinsem...@comcast.net: On Sep 23, 2009, at 7:58 AM, FMH wrote: Dear All, Let: dp: depth of the river tp: temperature with respect to depth We can have

Re: [R] Problem in graph plotting

2009-09-23 Thread baptiste auguie
Try this, d - na.omit(data.frame(tp,dp)) plot(d, t=l, ylim=rev(range(d$dp))) ?na.omit HTH, baptiste 2009/9/23 FMH kagba2...@yahoo.com: Thank you for the code. I found that the coding does not work if there is an NA in dp variable. For instance; # dp -

Re: [R] Putting a text box in a plot

2009-09-21 Thread baptiste auguie
Hi, Maybe the textplot() function in the gplots package? HTH, baptiste 2009/9/21 Sergey Goriatchev serg...@gmail.com: Hello everyone, I have a plot and I want to but a (formatted) box containing text and numbers, say: Mean: 0.1 St.Deviation: 1.1 Skewness: 1.1 Kurtosis: 0.5 I know

Re: [R] Putting a text box in a plot

2009-09-21 Thread baptiste auguie
() function. No, there must be another function somewhere that produces these text boxes. Best, Sergey On Mon, Sep 21, 2009 at 11:49, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Maybe the textplot() function in the gplots package? HTH, baptiste 2009/9/21 Sergey Goriatchev serg

<    1   2   3   4   5   6   7   8   >