Re: [R] recognizing variable-names of cast() (package: reshape)

2009-11-22 Thread hadley wickham
Hi David, The variable names of mma are sp, dentro, variable and value - area is not a variable in that data frame. Hadley On Sun, Nov 22, 2009 at 9:48 PM, David Douterlungne daviddou...@hotmail.com wrote: Dear R Users, Reshape seems to be very useful for data-manipulation, but I am

Re: [R] formatting dates in axis labels (ggplot2)

2009-11-20 Thread hadley wickham
Hi Michael, I'm having trouble figuring out how to format Date variables when used as axis labels in graphs. The particular case here is an attempt to re-create Nightingale's coxcomb graph with ggplot2, where I'd like the months to be labeled as Mar 1885, Apr 1885, using a date format of

Re: [R] Presentation of data in Graphical format

2009-11-18 Thread hadley wickham
Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. Given that you have neither provided your data, nor explained what you are trying to uncover from it, what sort of advice do you expect to get? Hadley -- http://had.co.nz/

Re: [R] Presentation of data in Graphical format

2009-11-18 Thread hadley wickham
so there are many such posts and dept with varied duties and times resp Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 9:15 PM, hadley wickham h.wick...@gmail.com wrote: Yes I tried all the basic ones like box plot, pie chart, etc

[R] Escaping regular expressions

2009-11-13 Thread Hadley Wickham
Hi all, Is there a method for escaping strings to be used regular expressions? i.e. if I have a user supplied string that I'd like to use as a fixed component is there a method that will turn (e.g.) .$^ into \\.\\$\\^ ? Thanks, Hadley -- http://had.co.nz/

Re: [R] Escaping regular expressions

2009-11-13 Thread Hadley Wickham
), fixed = TRUE) On Fri, Nov 13, 2009 at 11:33 AM, Hadley Wickham had...@rice.edu wrote: Hi all, Is there a method for escaping strings to be used regular expressions?  i.e. if I have a user supplied string that I'd like to use as a fixed component is there a method that will turn (e.g

Re: [R] How to show all the functions and classes that are defined in a library?

2009-11-13 Thread hadley wickham
On Fri, Nov 13, 2009 at 9:53 AM, Peng Yu pengyu...@gmail.com wrote: library(some_library_name) Try help(package = some_library_name) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] By processing on two variables at once?

2009-11-12 Thread hadley wickham
aggregate(dat$value, list(dat$x, dat$y), mean)  Group.1 Group.2  x 1       1       1 15 2       1       2 30 newdat -aggregate(dat$value, list(dat$x, dat$y), mean) names(newdat) - c(x,y,bquote(mean(value)) ) That bquote isn't necessary because you're already working with strings. c(x = 1, y

Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread hadley wickham
See the above example. Is there a way to make 'drop=FALSE' as global default, so that when I say 'tmp[,1]', R will treat it as 'tmp[,1,drop=FALSE]'? The following code won't change the defaults, but it would at least let you know when you're making the mistake: trace_all - function(fs,

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

2009-11-10 Thread Hadley Wickham
If you don't want to preserve factor levels when subsetting use characters. There are very few other differences in behavior. Hadley On Tuesday, November 10, 2009, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, subset has a 'drop' argument that I had often mistaken for the

Re: [R] Extracting matched expressions

2009-11-09 Thread Hadley Wickham
: Is this what you want: x - ' one two three ' y - sub(.*?([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([ehrt]{5}).*, +     \\1 \\2 \\3, x, perl=TRUE) unlist(strsplit(y, ' ')) [1] one   two   three On Sun, Nov 8, 2009 at 1:51 PM, Hadley Wickham had...@rice.edu

Re: [R] Complicated For Loop (to me)

2009-11-09 Thread hadley wickham
Have a look at ?split Hadley On Mon, Nov 9, 2009 at 10:41 AM, agm. amur...@vt.edu wrote: Hello, I'm trying to run a loop that will subset my data into specific sets by regions and by race/ethnicity.  I'm trying to do this fairly compactly, and I cannot get this to work. A simple version

[R] Extracting matched expressions

2009-11-08 Thread Hadley Wickham
Hi all, Is there a tool in base R to extract matched expressions from a regular expression? i.e. given the regular expression (.*?) (.*?) ([ehtr]{5}) is there a way to extract the character vector c(one, two, three) from the string one two three ? Thanks, Hadley -- http://had.co.nz/

Re: [R] map of a country and its different geographical levels

2009-11-07 Thread hadley wickham
If readShapePoly() (deprecated - use readShapeSpatial() instead) says that the data are not polygons, then they are not. If you want to fill administrative boundaries polygons, you need polygons, not lines. The source you are using is based on OpenStreetMaps, so more likely to be lines, and as

Re: [R] Patterned shading in ggplot

2009-11-04 Thread hadley wickham
Hi Paul, You might want to try the gray colour scale - scale_fill_grey() Unfortunately grid (the underlying graphics library that ggplot2 uses) does not currently support patterns. Hadley On Wed, Nov 4, 2009 at 4:17 AM, Paul Chatfield p.s.chatfi...@rdg.ac.uk wrote: Am trying to produce a

Re: [R] Safe way to automatically install required packages...

2009-11-02 Thread hadley wickham
If you package depends on another package, it will be automatically installed. Hadley On Mon, Nov 2, 2009 at 12:56 PM, Jonathan Greenberg greenb...@ucdavis.edu wrote: R-helpers:   I'm working on an r-package that I want to make as easy-to-use as possible for a novice R-user, which includes

Re: [R] multiple pages with ggplot2 facet_wrap?

2009-10-30 Thread hadley wickham
On Wed, Oct 28, 2009 at 8:19 PM, Bill Gillespie bi...@metrumrg.com wrote: I currently use lattice functions to produce multiple pages of plots using the layout argument to specify the number of rows and columns of panels, e.g., xyplot(price ~ carat | clarity, diamonds, layout = c(2, 2))

Re: [R] The system cannot find the file specified

2009-10-29 Thread hadley wickham
Do you have write permission in C:\Program Files\R\R-2.9.2\library?  It could be that the installer just tried to create the QRMlib subdir, and failed, and that's why it doesn't exist. One possible reason for failure is that your virus checker prevented the R installer from creating a new

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

2009-10-29 Thread hadley wickham
I can reproduce it with for example x=c(-9.23, -9.56, -1.40) But adding a single positive number, even .001, fixes it, while adding a similar negative number introduces a new error message, so it really looks like a bug in ggplot2 when all the values are negative. Report it to the

Re: [R] GGPLOT2 Different Layers Different X Values

2009-10-28 Thread Hadley Wickham
Hi John, Could you please provide a small reproducible example? Thanks, Hadley Sent from my iPhone On 26/10/2009, at 6:50 PM, Jonathan Bleyhl jonathan_ble...@affymetrix.com wrote: I'm trying to plot values based on a date and then overlay a histogram also by date. The problem is that

Re: [R] ggplot2: stat_bin ..count.. with geom_text when NA is present

2009-10-28 Thread hadley wickham
Hi Bryan, Thanks for the reproducible example. The problem is actually in your code, not mine ;) You probably want: y = min(res, na.rm = TRUE) - 0.1 * diff(range(res, na.rm = TRUE)) Hadley (drop = TRUE solves a difference problem - it controls whether or not to remove bins with zero count)

Re: [R] Sandard deviation calculation

2009-10-26 Thread hadley wickham
What are the values of  length((Ht_cm[type=='SD'][from_treeline=='above'])[1]) I suspect the error is in the subsetting - the following seems more plausible: Ht_cm[type=='SD' from_treeline=='above'] Hadley -- http://had.co.nz/ __

Re: [R] Putting names on a ggplot

2009-10-20 Thread hadley wickham
On Sun, Oct 18, 2009 at 10:29 AM, John Kane jrkrid...@yahoo.ca wrote: Thanks Stefan, the annotate approach works beautifully.  I had not got that far in Hadley's book apparently :( I'm not convinced though that the explaination you shouldn't use aes in this case since nampost, temprange,

Re: [R] Why points() is defined specially for a 1 by 2 matrix?

2009-10-19 Thread hadley wickham
 To answer one of your other questions: ggplot (and lattice) is/are very powerful, but base graphics are (a) easier to get your head around and (b) easier to adjust if you don't like the defaults.  Changing things just a little bit in ggplot can be difficult (as an example, the answer to your

Re: [R] ggplot2 scale_shape question

2009-10-14 Thread hadley wickham
Is there a way to have some points solid and some points hollow? I have two classes of points and there are so many points, that it's hard to see just the difference in shapes. I'd like to have one of the classes be hollow in addition to being a different shape. Any help would be grand.

Re: [R] Cacheing computationally expensive getter methods for S4 objects

2009-10-14 Thread hadley wickham
Just a note: this technique is called memoisation. Hadley On Wed, Oct 14, 2009 at 3:42 PM, Benilton Carvalho bcarv...@jhsph.edu wrote: Thank you very much, Martin. :) b On Oct 14, 2009, at 5:23 PM, Martin Morgan wrote: Steve Lianoglou wrote: Very clever, that looks to do the trick! I

Re: [R] splitting dataframe, assign to new dataframe, add new rows to new dataframe

2009-10-13 Thread hadley wickham
On Tue, Oct 13, 2009 at 6:57 AM, Ista Zahn istaz...@gmail.com wrote: I'm sure there's a really cool way to do this with plyr, although I don't know if my particular plyr version is much better. Anyway here it is: cmbine - read.csv(textConnection('names, mass, classes apple,0.50,1

Re: [R] Use R -- term and logo copyright?

2009-10-13 Thread hadley wickham
Can I use (a) the logo and/or (b) the slogan for the KCL R workshops? I think it is quite clear from my website that this is neither about the Springer book series nor about an R user conference. No, sorry, the logo/name should be used exclusively for the Springer series and the R User

Re: [R] lapply() reccursively

2009-10-13 Thread hadley wickham
Neither a1 nor 2:100 are lists, so it would seem that sapply would be more appropriate. The difference between lapply and sapply is the output, not the input. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list

Re: [R] ggplot cumsum refined question (?)

2009-10-06 Thread hadley wickham
It is much easier to do you data preparation before plotting. Cummul - ddply(subset(DF, precipitation!=NA), gauge_name, function(x){        x$Cummul - cumsum(x$precipitation)        x }) With a little less typing: Cummul - ddply(subset(DF, precipitation!=NA), gauge_name, transform,

Re: [R] Letter-based representation of pairwise comparisons

2009-10-06 Thread hadley wickham
Please provide a reproducible example. I've had problems with multcompLetters in the past, because I was giving it slightly incorrect input. Hadley On Tue, Oct 6, 2009 at 7:41 AM, goz garbage.collec...@hotmail.fr wrote: hello, i try to use the multcomp letters, but i have problems with my

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

2009-10-05 Thread 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(binwidth = 0.2) x = quote(cut) facets = facet_grid(as.formula(bquote(.~.(x p + facets That's what I'd recommend. You can also just do

Re: [R] Stranger Behavior -maybe not

2009-10-03 Thread hadley wickham
The point Duncan was making was What other value would you expect it to have after incrementing from 1 to 200 and stopping? Well, depending on the scoping rules of the language you are used to, you might expect i at the top-level to remain undefined. Hadley -- http://had.co.nz/

Re: [R] split-apply question

2009-10-02 Thread hadley wickham
On Fri, Oct 2, 2009 at 4:24 AM, jim holtman jholt...@gmail.com wrote: try this: x - read.table(textConnection(x1  x2  x3 + A   1    1.5 + B   2    0.9 + B   3    2.7 + C   7    1.8 + D   7    1.3), header=TRUE) closeAllConnections() do.call(rbind, lapply(split(seq(nrow(x)), x$x1),

Re: [R] Condition to factor (easy to remember)

2009-09-30 Thread hadley wickham
On Wed, Sep 30, 2009 at 2:32 PM, Ista Zahn istaz...@gmail.com wrote: An extremely verbose, but (in my view) easy to understand approach is: data.f - data; data.f[which(data = 10)] - levs[1]; data.f[which(data 10)] - levs[2]; data.f - factor(data.f) All those which()s are unnecessary. And

Re: [R] sort dates within a factor

2009-09-29 Thread hadley wickham
On Tue, Sep 29, 2009 at 6:58 AM, xavier.char...@free.fr wrote: Apologies for the misunderstanding. I can come up with a solution that might suit your needs: library(plyr) out - ddply(test, .(nr), function(x) data.frame(date=x$date, index=rank(-as.integer(x$date out[is.na(out$nr) |

Re: [R] 3D to 2D projection

2009-09-28 Thread hadley wickham
Have you used persp or trans3d before? Here is a little piece of data that I am want to convert to 2d. I can plot (x,z) or (z,y). I know there is a better way to convert it to 2d. I did it long time back in my 3d geometry class. http://en.wikipedia.org/wiki/3D_projection ? Hadley --

Re: [R] How to assess object names within a function in lapply or l_ply?

2009-09-28 Thread hadley wickham
or with l_ply (plyr package) l_ply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x The best way to do this is to supply both the object you want to iterate over, and its names. Unfortunately it's slightly difficult to create a data structure of the correct form to do this

Re: [R] How to assess object names within a function in lapply or l_ply?

2009-09-28 Thread hadley wickham
many thanks for your answer and for the enormous work you put into plyr, a really powerful package. For now, I will solve my problem with a variable label attribute, I usually attach to columns in data frames. I asked the list, because I thought, I am overlooking something trivial, since

Re: [R] R and REST API's

2009-09-28 Thread hadley wickham
On Mon, Sep 28, 2009 at 9:01 AM, Gary Lewis gary.m.le...@gmail.com wrote: Hi - Many organizations now make their data available as XML via a REST web service architecture. Is there any R package or facility to access this type of data directly (eg, to make the HTTP GET request and have the

Re: [R] packGrob and dynamic resizing

2009-09-25 Thread hadley wickham
On Fri, Sep 25, 2009 at 7:55 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Thank you Paul, I was convinced I tried this option but I obviously didn't! In ?packGrob, the user is warned that packing grobs can be slow. In order to quantify this, I made the following comparison of 3

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread hadley wickham
wtf - factor(x, levels(c(levels(wtf), NA), exclude=NULL) xtabs (~ wtf, exclude=NULL, na.action=na.pass) Also see addNA. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] R crashes when packages 'impute' and 'GeneMeta' are used together.

2009-09-21 Thread hadley wickham
Well, the title says all for this one. Not really. What do you mean by crash? What do you mean by used together? Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Working around 256 byte variable names? + trouble opening large file

2009-09-21 Thread hadley wickham
On Mon, Sep 21, 2009 at 3:04 PM, A Singh aditi.si...@bristol.ac.uk wrote: Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T)

Re: [R] Working around 256 byte variable names? + trouble opening large file

2009-09-21 Thread hadley wickham
From: hadley wickham h.wick...@gmail.com Don't use attach? Obvously good advice but why? Philosophically, it's better to be explicit than implicit, and the extremely non-local effects of attach can make debugging difficult. Hadley -- http://had.co.nz

Re: [R] eval(expr) without printing to screen?

2009-09-20 Thread hadley wickham
Here is a simpler mockup which shows the issue: x = data.frame(rbind(c(1,2,3),c(1,2,3))) xnames = c(a, b, c) names(x) = xnames for(i in 1:length(x)) { # Create a varying string expression expr = paste(y = x$, xnames[i], [1], sep=) # evaluate expression eval(parse(text=print(expr)))

Re: [R] why is nrow() so slow?

2009-09-15 Thread hadley wickham
On Tue, Sep 15, 2009 at 9:48 AM, ivo welch ivo...@gmail.com wrote: dear R wizards:  here is the strange question for the day.  It seems to me that nrow() is very slow.  Let me explain what I mean: ds= data.frame( NA, x=rnorm(1) )   ##  a sample data set system.time( { for (i in 1:1)

Re: [R] why is nrow() so slow?

2009-09-15 Thread hadley wickham
PS: Any speed suggestions are appreciated.  This is experimenting time for me. You might want to check out the plyr package - it incorporates everything I know about making these sorts of operations fast. The next version will do even better. Hadley -- http://had.co.nz/

Re: [R] R Memory Usage Concerns

2009-09-14 Thread hadley wickham
I think this is just because you picked short strings. If the factor is mapping the string to a native integer type, the strings would have to be larger for you to notice: object.size(sample(c(a pretty long string, another pretty long string), 1000, replace=TRUE)) 8184 bytes

Re: [R] R Memory Usage Concerns

2009-09-14 Thread hadley wickham
its 32-bit representation. This seems like it might be too conservative for me, since it implies that R allocated exactly as much memory for the lists as there were numbers in the list (e.g. typically in an interpreter like this you'd be allocating on order-of-two boundaries, i.e. sizeof(obj)

Re: [R] ggplot2::qplot() -- arbitary transformations of coordinate system?

2009-09-12 Thread hadley wickham
Is there a place to find a list of the legal values for the coord_trans parameters. I spent a bunch of time searching the ggplot2 docs and r-help for same without success. I also made an attempt at looking at the code in R which also failed. In the book, or with apropos(^Trans, ignore = F)

Re: [R] ggplot2: deterministic position_jitter geom_line with position_jitter

2009-09-12 Thread hadley wickham
On Sat, Sep 12, 2009 at 1:34 PM, Stephan Kolassa stephan.kola...@gmx.de wrote: Dear guRus, I am starting to work with the ggplot2 package and have two very dumb questions: 1) deterministic position_jitter - the jittering is stochastic; is there any way to get a deterministic jittering? For

Re: [R] barplot with lines instead of bars

2009-09-08 Thread hadley wickham
What's the difference between a line and a thin bar? Hadley On Tue, Sep 8, 2009 at 12:17 PM, rafamoralrafa_moral2...@yahoo.com.br wrote: I'm sorry, but I think I was misunderstood. What I need is something like this: http://img525.imageshack.us/img525/2818/imagemyu.jpg Lines instead of

Re: [R] Andrews plot

2009-09-07 Thread hadley wickham
On Mon, Sep 7, 2009 at 8:36 AM, Petr PIKALpetr.pi...@precheza.cz wrote: Dear all Colleague of mine ask me if R is capable of Andrews plot like andrewsplot(x) in Matlab. Quick search did not reveal anything but before I start to write any routine I would like to ask this ingenious audience

Re: [R] ggplot2::qplot() -- arbitary transformations of coordinate system?

2009-09-06 Thread hadley wickham
Hi Michael, You could use aes(y = 1000 * myyvar) and coord_trans(trans_y = inverse) Hadley On Sun, Sep 6, 2009 at 6:30 AM, Michael Kubovykub...@virginia.edu wrote: Hi Stephen, Because coord_trans() does all the work of plotting the original values on the tranformed scale. See ?coord_trans.

Re: [R] where did ggplot go?

2009-09-04 Thread hadley wickham
Hi Gene, Yes, ggplot2 has replaced ggplot. Hadley On Fri, Sep 4, 2009 at 12:58 PM, Gene Leynesgleyne...@gmail.com wrote: This must be explained somewhere, but I've been searching for a couple of hours and not found it. What happened to ggplot?  It appears to be missing on CRAN, except in

Re: [R] Avoiding loops

2009-09-02 Thread hadley wickham
Would like some tips on how to avoid loops as I know they are slow in R They are not slow. They are slower than vectorised equivalents, but not slower than apply and friends. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list

Re: [R] Sapply

2009-08-30 Thread hadley wickham
On Sun, Aug 30, 2009 at 5:08 PM, Noah Silvermann...@smartmediacorp.com wrote: Hi, I need a bit of guidance with the sapply function.  I've read the help page, but am still a bit unsure how to use it. I have a large data frame with about 100 columns and 30,000 rows.  One of the columns is

Re: [R] Google's R Style Guide

2009-08-29 Thread hadley wickham
An opening curly brace should never go on its own line; I tend to do this: f - function() {  if (TRUE)    {      cat(TRUE!!\n)    } else {      cat(FALSE!!\n)    } } (I don't usually put one-liners in if/else blocks; here I would have used ifelse) I haven't seen many others

Re: [R] Google's R Style Guide

2009-08-29 Thread hadley wickham
But in interactive use the R parser is constrained to work a line at a time (unless it could predict what you were going to type next ;) Hadley On Sat, Aug 29, 2009 at 5:05 PM, John Sorkinjsor...@grecc.umaryland.edu wrote: For my money, and perspective as one who has written a compiler, this

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
Perhaps most of you have already seen this?  http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley -- http://had.co.nz/

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html I see you repeated (or independently invented?) the bad rule about closing braces.  They should usually go on their own line, but not when followed by an else clause. That was an

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. I totally agree. The main purpose of my style guide is so that my students write code that I can easily read, understand and

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line. It seems to me that the opening an dosing curly brace should go on their own lines to allow the reader to immediately know what is

Re: [R] Transform data for repeated measures

2009-08-28 Thread hadley wickham
On Thu, Aug 27, 2009 at 6:37 PM, Richardson, Patrickpatrick.richard...@vai.org wrote: I have a dataset that I'm trying to rearrange for a repeated measures analysis: It looks like: patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h fev18h drug 201     2.46   2.68   2.76  

Re: [R] Applying do.call to a data.frame using function arguments

2009-08-26 Thread hadley wickham
On Wed, Aug 26, 2009 at 11:31 AM, miller_2555nabble.30.miller_2...@spamgourmet.com wrote: miller_2555 wrote: I'm trying to convert a data.frame to a series of strings (row-wise). There was a very good discussion awhile back (2002) entitled [R] string concatenate across rows of a matrix??

Re: [R] ggplot2: geom_smooth and legend

2009-08-26 Thread hadley wickham
Hi Benoit, You could turn the standard errors off with se = F. Then they'll be removed from the legend as well. Hadley On Tue, Aug 18, 2009 at 7:43 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Sorry I forgot the code that goes with **CODE desorb_plot-ggplot() +      

[R] CRAN (and crantastic) updates this week

2009-08-24 Thread Hadley Wickham
CRAN (and crantastic) updates this week New packages Updated packages New reviews --- This email provided as a service for the R community by http://crantastic.org. Like it? Hate it? Please let us know: crana...@gmail.com.

Re: [R] CRAN (and crantastic) updates this week

2009-08-24 Thread hadley wickham
* SensoMineR, by padmanabhan.vijayan http://crantastic.org/reviews/25 * plyr, by eamani http://crantastic.org/reviews/24 This email provided as a service for the R community by http://crantastic.org. Like it? Hate it? Please let us know: crana...@gmail.com. On Mon, Aug 24, 2009 at 4:18 PM, Hadley

Re: [R] Is there a fast way to do several hundred thousand ANOVA tests?

2009-08-23 Thread hadley wickham
You might find the article Computing Thousands of Test Statistics Simultaneously in R in http://stat-computing.org/newsletter/issues/scgn-18-1.pdf helpful. Hadley On Sun, Aug 23, 2009 at 7:55 PM, big permiebigper...@gmail.com wrote: Dear R users, I have a matrix a and a classification vector

Re: [R] ggplot2 legend problem

2009-08-19 Thread hadley wickham
On Tue, Aug 18, 2009 at 11:10 PM, Chris Friedlcfrieda...@gmail.com wrote: Still struggling with this. A further example using a slightly different organisation of the data. The factors A and B are included in the dataframe in an attempt to get ggplot to generate a legend automatically. x -

Re: [R] ggplot2: override facet names in facet_wrap?

2009-08-12 Thread hadley wickham
That's on the to do list :( Hadley On Tue, Aug 11, 2009 at 10:00 PM, Ben Bolkerbol...@ufl.edu wrote:  Thanks.  I can get it to work for facet_grid (which will do for my current purposes) but am curious about whether there's a way to do the same for facet_wrap (which doesn't have a labeller

Re: [R] Is there a summary on different version of 'apply' functions? What is the meaning of the prefixes?

2009-08-11 Thread hadley wickham
You might also want to have a look at the plyr package, http://had.co.nz/plyr. This package is an attempt to standardise and make consistent the various common uses of apply and friends. Hadley On Tue, Aug 11, 2009 at 3:09 PM, Peng Yupengyu...@gmail.com wrote: Hi, There are quiet a few

Re: [R] ggplot2: override facet names in facet_wrap?

2009-08-11 Thread hadley wickham
Have a look at the code and examples of label_value and label_both. They should suggest how to write your own labeller to do what you want. Hadey On Tue, Aug 11, 2009 at 1:44 PM, Ben Bolkerbol...@ufl.edu wrote:  just a quick question (to which I suspect the answer is no): does anyone know if,

[R] ggplot2 course: 19 October, Austin TX / the web

2009-08-04 Thread Hadley Wickham
Hi all, On October 19, I'll be offering a one data ggplot2 course in conjunction with the ISMI Manufacturing Week. The course is open to all and you can attend in person (Austin TX) or over the web. More information available from http://lookingatdata.com/ismi-2009/ Regards, Hadley --

Re: [R] Help with reshaping data.frame

2009-08-03 Thread hadley wickham
On Mon, Aug 3, 2009 at 5:23 PM, dav...@rhotrading.com wrote: I'm having trouble reshaping a data.frame from long to wide. (I think that's the right terminology; feel free to educate me.) I've looked at the reshape function and package and plyr package, but I can't quite figure out how to do

Re: [R] tweak a bit the legend wiht ggplot2

2009-07-31 Thread hadley wickham
Hi Benoit, Unfortunately there's currently no way to do that - the legend automatically corresponds to the geom in the plot. Hadley On Thu, Jul 23, 2009 at 11:30 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi all, I've this ggplot2 graph

Re: [R] roclet

2009-07-24 Thread hadley wickham
On Fri, Jul 24, 2009 at 9:08 AM, Steve Lianogloumailinglist.honey...@gmail.com wrote: Hi, On Jul 24, 2009, at 8:49 AM, n...@aleblanc.cotse.net n...@aleblanc.cotse.net wrote: Hi,  can anyone tell me what a roclet is exactly?  Is this terminology specific to R, or is it used in other

Re: [R] All possible linear models given multiple explaining variables

2009-07-22 Thread hadley wickham
Have a look at the meifly package, which also includes tools for visualising the resulting models. Hadley On Wed, Jul 22, 2009 at 7:28 AM, Thomas A. Groentagr...@gmail.com wrote: Hi, I would like to have a script/function (or write one) that can calculate the linear models for all possible

Re: [R] animated grid graphics

2009-07-21 Thread hadley wickham
Ups, I just realized that we have the possibility of using grid.remove(..., redraw = FALSE) which is more or less what I was looking for. But I'm still wondering if its possible to remove a viewport from a viewport tree: I've talked with Paul about this (for the general case of modifying

Re: [R] animated grid graphics

2009-07-21 Thread hadley wickham
Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. This movie is also much more compatible with all kinds of machines. It might be that you can get your grid animation working on your own

Re: [R] How to replace NAs in a vector of factors?

2009-07-21 Thread hadley wickham
On Tue, Jul 21, 2009 at 7:39 PM, Gene Leynesgleyne...@gmail.com wrote: # Just when I thought I had the basic stuff mastered # This has been quite perplexing, thanks for any help ## Here's the example: db1=data.frame(    olditems=c('soup','','','','nuts'),    prices=c(4.45, 3.25, 4.42,

Re: [R] strange dlply behavior

2009-07-21 Thread hadley wickham
Hi Damien, This is because of a small bug. You can work around it by explicitly using the force function - dlply(d, V1, force). The default will be fixed in the next version. Regards, Hadley On Tue, Jul 21, 2009 at 11:18 AM, Damien Mooredamienlmo...@gmail.com wrote: I'm running R 2.9.1 on

Re: [R] GGPLOT Clipping Regions

2009-07-20 Thread hadley wickham
On Fri, Jul 17, 2009 at 3:39 AM, Alex Brownfisht...@compsoc.man.ac.uk wrote: Sure thing, an example.: ggplot (data.frame(name=letters[1:3],value=c(1,4,9),type=c(fun,fun,not fun)),aes(x=name,y=value,fill=type,label=paste(value is ,value))) + geom_bar() + coord_flip() + geom_text(hjust=0)

Re: [R] Simulate residuals with different properties for a linear model (regression)

2009-07-20 Thread hadley wickham
for educational purposes I wonder if it is possible to simulate different data sets (or specifically residuals) for a linear regression. I would like to show my students residuals with different means, variances and distributions (normal, but also not normal) in the plots created with the

Re: [R] ggplot2: geom_errorbarh()

2009-07-17 Thread hadley wickham
/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : mercredi 15 juillet 2009 14:52 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_errorbarh() In ggplot2, you'll want to use size. Hadley On Wed

Re: [R] GGPLOT Clipping Regions

2009-07-16 Thread hadley wickham
Could you please give a reproducible example? Thanks, Hadley On Thu, Jul 16, 2009 at 5:41 PM, Alex Browna...@transitive.com wrote: Hi there,        I'm trying to find out the command to stop clipping to plot region in ggplot.        I have a bar chart (axis flipped) with labels on the bars,

Re: [R] ggplot2: geom_errorbarh()

2009-07-15 Thread hadley wickham
-Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : dimanche 12 juillet 2009 11:04 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_errorbarh() Hi Benoit, What do you expect width to do?  You are already setting the left and right

Re: [R] ggplot2: geom_errorbarh()

2009-07-12 Thread hadley wickham
Hi Benoit, What do you expect width to do? You are already setting the left and right extents with xmin and xmax. Hadley On Thu, Jul 9, 2009 at 10:37 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi all, quick question: is the optional command width effective in the

Re: [R] curve from a formula with ggplot2

2009-07-12 Thread hadley wickham
a curve from a formula. I'm looking for the equivalent of curve() in ggplot2, Hadley Wickham mentions geom_curve, but as far as I've seen in the help it doesn't exist. My need is to plot a regular scatter plot of experimental data (easy to do actually) and then add the fitting model according

Re: [R] Strange error in qplot

2009-07-12 Thread hadley wickham
Hi megh, Unfortunately there's a known bug which prevents you from setting the y axis title in this way. Instead you can do : qplot(...) + scale_y_continuous() I think I've figured out a work around and it will be fixed in a future release. Hadley On Mon, Jul 13, 2009 at 2:15 AM,

Re: [R] strata -- really slow performance

2009-07-12 Thread hadley wickham
In this simple example, it took less than half a second to generate the result. That is on a 2.93 Ghz MacBook Pro. So, for your data, the code would look something like this: system.time(DF.new - do.call(rbind,                              lapply(split(patch_summary,

Re: [R] how to keep row name if there is only one row selected from a data frame

2009-07-12 Thread hadley wickham
On Mon, Jul 13, 2009 at 5:55 AM, Weiwei Shihelprh...@gmail.com wrote: Hi, there: Assume I have a dataframe with rownames like A with rownames like a to e, A  [,1] [,2] a    1    6 b    2    7 c    3    8 d    4    9 e    5   10 when I use A[1,], I lost the rowname for it, like below.

Re: [R] NA values trimming

2009-07-06 Thread hadley wickham
On Mon, Jul 6, 2009 at 12:12 AM, nykn...@nyk.ch wrote: Thanks for your reply! This is what I was looking for! I'm using nas1 - apply(data_matrix,1,function(x)sum(is.na(x))/nrow(data_matrix)) nas2 - apply(data_matrix,2,function(x)sum(is.na(x))/ncol(data_matrix)) You can simplify this a

Re: [R] ReShape chicks example - line plots

2009-07-06 Thread hadley wickham
On Mon, Jul 6, 2009 at 8:22 PM, Mark Knechtmarkkne...@gmail.com wrote: Hi,   In the examples from the ReShape package there is a simple example of using melt followed by cast that produces a smallish amount of output about the chicks database. Here's the code: library(reshape)

Re: [R] What command lists everything in a package?

2009-07-05 Thread hadley wickham
2) Related to the above, how do I tell what packages are currently loaded at any given time so that I don't waste time loading things that are already loaded? search() tells me what's available, but what's loaded? The best I can find so far goes like this: Loading something a second time

Re: [R] Skeleton Package to Flesh Out?

2009-07-05 Thread hadley wickham
Also make sure to check roxygen (from roxygen.org) - it makes package documentation much much easier. Ironically, the documentation for roxygen currently leaves something to be desired but I think Peter and Manuel are working on it. Hadley On Sat, Jul 4, 2009 at 3:59 PM, Jason

Re: [R] OK - I got the data - now what? :-)

2009-07-05 Thread hadley wickham
  I think the root cause of a number of my coding problems in R right now is my lack of skills in reading and grabbing portions of the data out of arrays. I'm new at this. (And not a programmer) I need to find some good examples to read and test on that subject. If I could locate which column

Re: [R] ggplot2: Boxplot with given box size

2009-07-05 Thread hadley wickham
Hi Malcolm, You need to tell geom_boxplot not to use stat_boxplot: geom_boxplot(aes(lower=y_q1, upper=y_q3, middle=y_med, ymin=y_min, ymax=y_max), stat = identity) Hadley On Mon, Jul 6, 2009 at 6:55 AM, Malcolm Ryanmalco...@cse.unsw.edu.au wrote: Is there anyway in ggplot2 to set the

Re: [R] help with dealing with integer(0) returns from grep used within a conditional loop

2009-07-04 Thread hadley wickham
On Sat, Jul 4, 2009 at 7:56 PM, Mark Kimpelmwkim...@gmail.com wrote: I am using grep to locate colnames to automate a report build and have run into a problem when a colname is not found. The use of integer(0) in a conditional statement seems to be a no no as it has length 0. Below is a

<    2   3   4   5   6   7   8   9   10   11   >