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

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

Re: [R] Exporting an rgl graph

2010-04-15 Thread baptiste auguie
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 fact there may not even exist a third-party post-processing route available at this time

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

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 chri...@austwaterenv.com.au wrote: Hi all, I have written a note near each of my graphs using mtext.

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

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

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 math_da...@hotmail.com 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

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 de...@tetonedge.net 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

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 jun.shen...@gmail.com wrote: If you do plotting in a loop, then you need to print it to the device.

[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

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 deepayan.sar...@r-project.org 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] 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-19 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 murdoch.dun...@gmail.com wrote: On 18/05/2010 4:36 PM, baptiste auguie wrote: Dear

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 bt_jan...@yahoo.de wrote: Dears, before I start programming my own function I would like to ask you whether there is any function already available that

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] Greek symbols on ylab= using barchart() {Lattice}

2009-12-09 Thread baptiste auguie
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 as y-label, with greek letter mu replacing u AND 3 going as a power. These commands works in general: plot.new() text(0.5, 0.5,

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] multidimensional point.in.polygon??

2009-12-10 Thread baptiste auguie
- baptiste auguie baptiste.aug...@googlemail.com wrote in message news:de4e29f50912040550m71fbffafnfa1ed6e0f4451...@mail.gmail.com... Hi, Yet another one of my very naive ideas on the subject: maybe you can first evaluate the circumscribed and inscribed

Re: [R] Avoid for-loop in creating data.frames

2009-12-10 Thread baptiste auguie
Hi, Is the following close enough? apply(set2, 2, function(x) x[is.na(x)]) HTH, baptiste 2009/12/10 Andreas Wittmann andreas_wittm...@gmx.de: Dear R-users, after several tries with lapply and searching the mailing list, i want to ask, wheter and how it is possibly to avoid the for-loop in

Re: [R] mutlidimensional in.convex.hull (was multidimensional point.in.polygon??)

2009-12-11 Thread baptiste auguie
2009/12/10 Charles C. Berry cbe...@tajo.ucsd.edu: [snipped] Many? set.seed(1234) ps - matrix(rnorm(4000),ncol=4) phull -  convhulln(ps) xs - matrix(rnorm(1200),ncol=4) phull2 - convhulln(rbind(ps,xs)) nrp - nrow(ps) nrx - nrow(xs) outside - unique(phull2[phull2nrp])-nrp done - FALSE

Re: [R] get the enclosing function name

2009-12-11 Thread baptiste auguie
Hi, .NotYetImplemented gives an example, function () stop(gettextf('%s' is not implemented yet, as.character(sys.call(sys.parent())[[1L]])), call. = FALSE) environment: namespace:base HTH, baptiste 2009/12/11 Hao Cen h...@andrew.cmu.edu: Hi, Is there a way to get the enclosing function

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

2009-12-13 Thread baptiste auguie
`[[.data.frame` and more generally see Rnews Volume 6/4, October 2006 Accessing the Sources. HTH, baptiste 2009/12/13 Guillaume Yziquel guillaume.yziq...@citycable.ch: Hello. I'm currently trying to wrap up data frames into OCaml via OCaml-R, and I'm having trouble with data frame

Re: [R] Combinations

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

Re: [R] problem with a densityplot

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

[R] fortune-like FAQ search

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

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

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

[R] expand.grid game

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

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
2009/12/19 David Winsemius dwinsem...@comcast.net: On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote: Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the following: how many 8-digit numbers have the sum of their digits

Re: [R] expand.grid game

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

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
for the list] 2009/12/19 David Winsemius dwinsem...@comcast.net: On Dec 19, 2009, at 2:10 PM, David Winsemius wrote: On Dec 19, 2009, at 1:36 PM, baptiste auguie wrote: 2009/12/19 David Winsemius dwinsem...@comcast.net: On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote: Dear list

Re: [R] expression()

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

[R] basic proto question

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

Re: [R] basic proto question

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

Re: [R] How to rotate an axis?

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

Re: [R] expand.grid game

2009-12-21 Thread baptiste auguie
participated, I have learned interesting things from a seemingly innocuous question. Best regards, baptiste 2009/12/21 Robin Hankin rk...@cam.ac.uk: Hi library(partitions) jj - blockparts(rep(9,8),17) dim(jj) gives 318648 HTH rksh baptiste auguie wrote: Dear list

Re: [R] String question

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

Re: [R] String question

2009-12-23 Thread baptiste auguie
Isn't paste doing exactly this? temp - c(November, December,Monday,Tuesday) paste(temp, collapse=,) # November,December,Monday,Tuesday HTH, baptiste 2009/12/23 Ted Harding ted.hard...@manchester.ac.uk: On 23-Dec-09 11:08:02, Knut Krueger wrote: Jim Lemon schrieb: Not as easy as I thought

Re: [R] Scaling error

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

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

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

Re: [R] subsetting by groups, with conditions

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

Re: [R] Histogram/BoxPlot Panel

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

Re: [R] Histogram/BoxPlot Panel

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

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

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

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

2010-01-03 Thread baptiste auguie
Hi, Using backticks might work to some extent, library(lattice) `my variable` = 1:10 y=rnorm(10) xyplot(`my variable` ~ y) but if your data is in a data.frame the names should have been converted, make.names('my variable') [1] my.variable HTH, baptiste 2010/1/3 Jay josip.2...@gmail.com:

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

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

Re: [R] postscript, greek lellters

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

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

Re: [R] Faster matrix operation?

2010-06-01 Thread baptiste auguie
On 1 June 2010 11:34, Peter Ehlers ehl...@ucalgary.ca 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,

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.

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,

Re: [R] Faster union of polygons?

2010-06-01 Thread baptiste auguie
Hi, I think you could use a concave hull from the alphahull package, http://yihui.name/en/2010/04/alphahull-an-r-package-for-alpha-convex-hull/ It may be difficult to find the right parameters if the polygons differ widely in edge lengths, though. HTH, baptiste On 2 June 2010 03:53, Remko

Re: [R] textbox in lattice

2010-06-02 Thread baptiste auguie
On 2 June 2010 07:55, Deepayan Sarkar deepayan.sar...@gmail.com wrote: Something like this should also work, except that the grob produced by tableGrob() doesn't seem to know its height. Indeed, I have not been successful in writing good widthDetails/heightDetails methods for this grob since

Re: [R] textbox in lattice

2010-06-03 Thread baptiste auguie
Hi, On 3 June 2010 05:26, Paul Murrell p.murr...@auckland.ac.nz wrote: Or the same drawing calculations have to be repeated within width/heightDetails - those methods should get run within the same graphical context as the drawDetails method. Yes, the idea crossed my mind, but I did not

Re: [R] Greek letters and formatted text

2010-06-05 Thread baptiste auguie
Try text(0.8,1,bquote(*sigma*==.(round(m,2))*±*.(round(sig,2 ?bquote ?plotmath On 5 June 2010 11:36, Thomas Bschorr bsch...@phys.ethz.ch wrote: Hi, I desperately try to do s.th. like m=1.23455 sig=0.84321 plot(1,1) text(0.8,1,sprintf(Sigma=%1.2f±%1.2f,m,sig)) where actually the

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

2010-06-05 Thread baptiste auguie
15:30, Deepayan Sarkar deepayan.sar...@r-project.org wrote: On Tue, May 18, 2010 at 6:32 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear all, I got a couple of warnings using panel.levelplot.raster, In panel.levelplot.raster(..., interpolate = TRUE) :  'y' values

Re: [R] textbox in lattice

2010-06-06 Thread baptiste auguie
such duplication of calculations at drawing time), or do they have to be completely independent in the implementation? Best, baptiste On 3 June 2010 07:58, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, On 3 June 2010 05:26, Paul Murrell p.murr...@auckland.ac.nz wrote: Or the same drawing

Re: [R] Loading an image/picture (png/jpeg/...) to screen...

2010-06-06 Thread baptiste auguie
Hi, Try this, library(png) example(readPNG) HTH, baptiste On 6 June 2010 13:46, oliver oli...@first.in-berlin.de wrote: Hello, how can I load an external picture/image file to screen? I want to use locator() then to get coordinates of that picture... ...in other words I want to use R

Re: [R] Creating pdf report

2010-06-06 Thread baptiste auguie
Hi, ggplot2 and lattice also provide convenient ways to arrange multiple plots on a page. For tables, there's also a function based on Grid graphics in the gridExtra package. A typical dummy example might be, library(ggplot2) library(gridExtra) p = qplot(Sepal.Length, Petal.Length, data=iris,

Re: [R] Loading an image/picture (png/jpeg/...) to screen...

2010-06-06 Thread baptiste auguie
On 7 June 2010 01:16, Oliver oli...@first.in-berlin.de wrote: baptiste auguie baptiste.auguie at googlemail.com writes: Hi, Try this, library(png) example(readPNG) [...] If rasterImage would be available, I think this would be the right hint. It is available when you use the latest

Re: [R] drawing curve

2010-06-10 Thread baptiste auguie
The OP asked for a smooth curve, foo = splinefun(x,y) curve(foo, min(x), max(x)) # points(x,y) I'm sure a R wizard could make it a one-liner. HTH, baptiste On 10 June 2010 16:48, Mario Valle mva...@cscs.ch wrote: x-c(1:6) y-c(.01,.09,.08,.03,.001,.02) plot(x,y, type='l') Please try ?plot

Re: [R] Order labels in qplot() - ggplot2 {help}

2010-06-10 Thread baptiste auguie
Hi, You could reorder the factor levels before plotting, x$n = factor(x$n, levels=c(va,vp, letters[1:3])) last_plot() %+% x or you could avoid using factors in the first place, x - data.frame(cbind(n,p,pm,pn), stringsAsFactors=FALSE) last_plot() %+% x HTH, baptiste On Thu, Jun 10, 2010

[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)) +

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 jacobwege...@fastmail.fm wrote: In ggplot2, I would like to make a boxplot that has the following properties: (1) Contrary to

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 jsz...@mail.hzau.edu.cn

<    1   2   3   4   5   6   7   8   >