Re: [R] Last month on the Revolutions blog

2009-05-02 Thread hadley wickham
Hi David, I think the revolution blog is fantastic and a great service to the R community. Thanks for all your hard work! Hadley On Fri, May 1, 2009 at 4:54 PM, David M Smith da...@revolution-computing.com wrote: I write about R every weekday at http://blog.revolution-computing.com . In case

Re: [R] Overlaying graphs from different datasets with ggplot

2009-05-03 Thread hadley wickham
On Thu, Apr 30, 2009 at 2:03 PM, MUHC-Research villa...@dms.umontreal.ca wrote: Dear R-users, I recently began using the ggplot2 package and I am still in the process of getting used to it. My goal would be to plot on the same grid a number of curves derived from two distinct datasets. The

Re: [R] quick square root axes

2009-05-05 Thread hadley wickham
If you do write your own, the hardest part will be picking the nice tick marks.  They should be approximately evenly spaced, but at nice round values of the original variable:  that's hard to do in general.  R has the pretty() function for the linear scale, and doesn't do too badly on log

Re: [R] Do you use R for data manipulation?

2009-05-06 Thread hadley wickham
Take a look at plyr and reshape packages (http://had.co.nz/), I have a hunch that they would have saved me a lot of headache had I found out about them earlier :) As the author of these two packages, I'm admittedly biased, but I think R is unparalleled for data preparation, manipulation, and

Re: [R] Houston, TX Users Group

2009-05-06 Thread hadley wickham
Hi Robert, I'm organising one - sign up to the mailing list, http://groups.google.com/group/houston-r. I'm hoping to organise our first meeting this summer. Hadley On Wed, May 6, 2009 at 10:15 AM, Robert Sanford wob...@gmail.com wrote: I'm looking for a Users Group in or near Houston, TX.

Re: [R] by-group processing

2009-05-08 Thread hadley wickham
On Wed, May 6, 2009 at 8:12 PM, jim holtman jholt...@gmail.com wrote: Ths should do it: do.call(rbind, lapply(split(x, x$ID), tail, 1))         ID Type N 45900 45900    I 7 46550 46550    I 7 49270 49270    E 3 Or with plyr: library(plyr) ddply(x, id, tail, 1) plyr encapsulates the

Re: [R] ggplot2: recommended workaround for broken legend.position=top

2009-05-10 Thread hadley wickham
On Sun, May 10, 2009 at 10:32 AM, Zeljko Vrba zv...@ifi.uio.no wrote: Searching the mail archives I found that using legend.position as in p.ring.3 + opts(legend.position=top) is a known bug.  I tried doing p.ring.3 + opts(legend.position=c(0.8, 0.2)) which works, but the legend background

Re: [R] Help with reshape/reShape and indexing

2009-05-13 Thread hadley wickham
This does it more or less your way: ds - split(df, df$Name) ds - lapply(ds, function(x){x$Index - seq_along(x[,1]); x}) df2 - unsplit(ds, df$Name) tapply(df2$X1, df2[,c(Name, Index)], function(x) x) athough there may exist much easier ways ... Here's one way with the plyr and reshape

Re: [R] Function to read a string as the variables as opposed to taking the string name as the variable

2009-05-14 Thread hadley wickham
On Thu, May 14, 2009 at 12:16 PM, Lori Simpson lori.simp...@dc-energy.com wrote: I am writing a custom function that uses an R-function from the reshape package: cast.  However, my question could be applicable to any R function. Normally one writes the arguments directly into a function,

Re: [R] memory usage grows too fast

2009-05-14 Thread hadley wickham
On Thu, May 14, 2009 at 6:21 PM, Ping-Hsun Hsieh hsi...@ohsu.edu wrote: Hi All, I have a 1000x100 matrix. The calculation I would like to do is actually very simple: for each row, calculate the frequency of a given pattern. For example, a toy dataset is as follows. Col1    Col2    

Re: [R] assign unique size of point in xyplot

2009-05-15 Thread hadley wickham
On Thu, May 14, 2009 at 2:14 PM, Garritt Page page2...@gmail.com wrote: Hello,I am using xyplot to try and create a conditional plot.  Below is a toy example of the type of data I am working with slevel - rep(rep(c(0.5,0.9), each=2, times=2), times=2) tlevel - rep(rep(c(0.5,0.9), each=4),

Re: [R] ggplot2: annotating plot with mathematical formulae

2009-05-16 Thread hadley wickham
Hi Paul, Unfortunately that's not something that's currently possible with ggplot2, but I am thinking about how to make it possible. Hadley On Sat, May 16, 2009 at 7:48 AM, Paul Emberson em...@calidasoft.co.uk wrote: Hi Stephen, The problem is that the label on the graph doesn't get rendered

Re: [R] ggplot2 and Date class

2009-06-01 Thread hadley wickham
You might have an out-of-date version of the plyr package - try install.packages(plyr) Hadley On Mon, Jun 1, 2009 at 10:20 AM, Matt Frost mwfr...@gmail.com wrote: I'm trying to plot a time series in ggplot, but a date column in my data frame is causing errors. Rather than provide my own data,

Re: [R] Minor tick marks for date/time ggplot2 (this is better, but not exactly what I want)

2009-06-04 Thread hadley wickham
On Mon, Jun 1, 2009 at 2:18 PM, stephen sefick ssef...@gmail.com wrote: library(ggplot2) melt.updn - (structure(list(date = structure(c(11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, 13149, 11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418,

Re: [R] OT: Inference for R - Interview

2009-06-04 Thread hadley wickham
Is it really necessary to further advertise this company which already spams R-help subscribers? Hadley On Thu, Jun 4, 2009 at 10:41 PM, Ajay ohri ohri2...@gmail.com wrote: Dear All, Slightly off -non technical topic ( but hey it is Friday) Following last week's interview with REvolution

Re: [R] A very frustrating read.table error message

2009-06-06 Thread hadley wickham
On Sat, Jun 6, 2009 at 5:02 PM, Adam D. I. Kramera...@ilovebacon.org wrote: Dear Colleagues,        Occasionally I deal with computer-generated (i.e., websurvey) data files that haven't quite worked correctly. When I try to read the data into R, I get something like this: Error in

Re: [R] Looking for easy way to normalize data by groups

2009-06-08 Thread hadley wickham
On Mon, Jun 8, 2009 at 10:29 AM, Herbert Jägleherbert.jae...@uni-tuebingen.de wrote: Hi, i do have a dataframe representing data from a repeated experiment. PID is a subject identifier, Time are timepoints in an experiment which was repeated twice. For each subject and all three timepoints

Re: [R] how to substitute missing values (NAs) by the group means

2009-06-08 Thread hadley wickham
On Mon, Jun 8, 2009 at 8:56 PM, Mao Jianfengjianfeng@gmail.com wrote: Dear Ruser's I ask for helps on how to substitute missing values (NAs) by mean of the group it is belonging to. my dummy dataframe is: df       group traits 1  BSPy01-10     NA 2  BSPy01-10    7.3 3  BSPy01-10    

[R] Programmatically copying a graphic to the clipboard

2009-06-12 Thread Hadley Wickham
Hi all, Is there a cross-platform way to do this? On the mac, I cando this by saving an eps file, and then using pbcopy. Is it possible on other platforms? Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list

[R] [OT] VBA to save excel as csv

2009-06-15 Thread Hadley Wickham
Hi all, This is a little off-topic, but it is on the general topic of getting data in R. I'm looking for a excel macro / vba script that will export all spreadsheets in a directory (with one file per tab) into csv. Does anyone have anything like this? Thanks, Hadley -- http://had.co.nz/

[R] Learning S3

2009-06-18 Thread Hadley Wickham
Hi all, Do you know of any good resources for learning how S3 works? I've some how become familiar with it by reading many small pieces, but now that I'm teaching it to students I'm wondering if there are any good resources that describe it completely, especially in a reader-friendly way. So

Re: [R] Learning S3

2009-06-18 Thread Hadley Wickham
To: Hadley Wickham Cc: r-help Subject: Re: [R] Learning S3 There is a section on Object Orientation in MASS (I have 2nd ed). On Thu, Jun 18, 2009 at 12:06 PM, Hadley Wickhamhad...@rice.edu wrote: Hi all, Do you know of any good resources for learning how S3 works?  I've some how become familiar

Re: [R] Dataset suggestion sought

2009-06-18 Thread hadley wickham
In revising my book Regression Modeling Strategies for a second edition, I am seeking a dataset for exemplifying multiple regression using least squares.  Ideally the dataset would have 5-40 variables and 40-1 independent observations, and would generate significant interest for a wide

Re: [R] Roxygen vs Sweave for S4 documentation

2009-06-21 Thread hadley wickham
I have been using R for a while.  Recently, I have begun converting my package into S4 classes.  I was previously using Rdoc for documentation. Now, I am looking to use the best tool for S4 documentation.  It seems that the best choices for me are Roxygen and Sweave (I am fine with tex). Are

Re: [R] ggplot2 frequency Y axis label

2007-11-16 Thread hadley wickham
Hi Felipe, That's should be the default. How is it different to what you expect? Hadley On 11/16/07, Felipe Carrillo [EMAIL PROTECTED] wrote: Hi all: I wonder if ggplot2 can create histograms with frequency along the Y axis Felipe D. Carrillo Fishery Biologist US Fish Wildlife

Re: [R] Exponential Smoothing for ggplot2's stat_smooth()

2007-11-16 Thread hadley wickham
Hi Michael, To use stat_smooth as is, you need a smoothing function that basically works like lm. So you have two options: to make an interface to HoltWinters (or find another exponential smooth that already has that interface) or write your own stat object, which might look something like this:

Re: [R] Help Required in using cast (reshape package) function

2007-11-21 Thread hadley wickham
On 11/21/07, Punit Anand [EMAIL PROTECTED] wrote: Hello everyone, Since the fields in variables column are unique with respect to ID and fiscal year; any function like sum,min,max,mean etc will lead to the desired result You should probably check that, as the warning only occurs when

Re: [R] more outrageous plotting

2007-11-22 Thread hadley wickham
Hi Juan, Assuming that your data frame is named df, something like the following should work: library(ggplot) qplot(X, Y, data = df, colour = Z, label = Z, geom = text) + scale_colour_continuous(low=orange, high = blue) You can find out more about ggplot2 at http://had.co.nz/ggplot2. Hadley

Re: [R] Packages - a great resource, but hard to find the right one

2007-11-23 Thread hadley wickham
Above all there are lots of packages. As the software editor of the Journal of Statistical Software I suggested we should review R packages. No one has shown any enthusiasm for this suggestion, but I think it would help. Any volunteers? There are two common types of review. When reviewing

Re: [R] multiple comparisons/tukey kramer

2007-11-23 Thread hadley wickham
However, I don't know what exactly glht does, and the help file is extremely terse. It offers the following options (in contrMat()): contrMat(n, type=c(Dunnett, Tukey, Sequen, AVE, Changepoint, Williams, Marcus, McDermott), base = 1) The

Re: [R] Packages - a great resource, but hard to find the right one

2007-11-23 Thread hadley wickham
This is a strange argument. A good package will get a good review, which may help it to become better. A review of a weak package can point out how it can be fixed. Reviews will not become stale, just because packages are frequently updated by their authors (like some that could be

Re: [R] ggplo2: fixed extent greater than data?

2007-11-23 Thread hadley wickham
On 11/23/07, thegeologician [EMAIL PROTECTED] wrote: Hi everyone! I'm digging into ggplot for some while now, I must say it's great! But - as some others have posted before, and hadley knows very well himself - the documentation is lacking some bits... So I have to pose that question

Re: [R] Packages - a great resource, but hard to find the right one

2007-11-23 Thread hadley wickham
On 11/23/07, hadley wickham [EMAIL PROTECTED] wrote: Above all there are lots of packages. As the software editor of the Journal of Statistical Software I suggested we should review R packages. No one has shown any enthusiasm for this suggestion, but I think it would help. Any

Re: [R] Packages - a great resource, but hard to find the right one

2007-11-24 Thread hadley wickham
What do you mean here? Surely all packages authors aim to provide reliable and effective software. If they know that they are offering something unstable, they should say so clearly. In fact, they should wait until it is stable. Most R users are not researchers, but users. Now I'm

Re: [R] Communicating from one function to another

2007-11-26 Thread hadley wickham
On 11/26/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: Others have already answered your direct question but consider that what you may want without realizing it is object-oriented programming. I agree with Gabor, you're not actually looking for a global state, but a mutable object

Re: [R] ggplot2 melt function value

2007-11-29 Thread hadley wickham
Hi:I recently started using the melt function and found that it is very useful and powerful,however I can't seem to find the way to change the default column header value to my custom column name. melted data are data frames. You can names[..]-myvalue for renaming, but make sure you

Re: [R] Rating R Helpers

2007-11-30 Thread hadley wickham
A nice model might be http://www.workingwithrails.com/. It also suggests other possible measures of authority: * member of R core * packages written by/contributed to * R conference attended/presented at * contributer to wiki Hadley On 11/30/07, Doran, Harold [EMAIL PROTECTED] wrote:

Re: [R] ggplot2: Choosing colours

2007-12-03 Thread hadley wickham
Hi Thierry, Have a look at http://had.co.nz/ggplot2/scale_identity. (The way you are currently doing it only works because you are not using any kind of grouping/facetting, and I'm thinking about adding an explicit message/warning for this case) Hadley On 12/3/07, ONKELINX, Thierry [EMAIL

Re: [R] using color coded colorbars for bar plots

2007-12-03 Thread hadley wickham
On 12/2/07, Jim Lemon [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hi Jim, Thanks for getting back to me so quickly. I did look at color.legend, but that seems to plot colored blocks for the observations (in this case the mean) and not for the color.scale (which represents

Re: [R] using color coded colorbars for bar plots

2007-12-03 Thread hadley wickham
On 12/3/07, Bert Gunter [EMAIL PROTECTED] wrote: ... but the best option is not to do this kind of technicolor extravaganza at all! Yes, good point! And of a course of a scatterplot of mean vs variance will best reveal the relationship between the two variables. Hadley -- http://had.co.nz/

Re: [R] Multiple stacked barplots on the same graph?

2007-12-04 Thread hadley wickham
On Dec 4, 2007 10:34 AM, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Hi, I tried this method but it seems that there is something wrong with my data frame: when I type in: qplot(x=as.factor(Categorie),y=Total,data=mydata) It displays a graph with 2 points in each category... but if

Re: [R] color palette from red to blue passing white

2007-12-04 Thread hadley wickham
Hmm, I would have recommended colorRampPalette(c('dark red','white','dark blue'), space = Lab) where the 'space = Lab' part also makes sure that a perceptually-based space rather than RGB is used. I think the functions colorRamp() and (even more) colorRampPalette()

Re: [R] Multiple stacked barplots on the same graph?

2007-12-05 Thread hadley wickham
, Stéphane. hadley wickham wrote: On Dec 4, 2007 10:34 AM, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Hi, I tried this method but it seems that there is something wrong with my data frame: when I type in: qplot(x=as.factor(Categorie),y=Total,data=mydata

Re: [R] if/else for plot/lines?

2007-12-07 Thread hadley wickham
On Dec 7, 2007 4:28 AM, Roger Levy [EMAIL PROTECTED] wrote: I'm interested in writing a function that constructs a new plot on the current graphics device if no plot exists there yet, but adds lines to the existing plot if a plot is already there. How can I do this? It seems to me that the

Re: [R] R help mailing system configuration change?

2007-12-07 Thread hadley wickham
On 12/6/07, 정 태훈 [EMAIL PROTECTED] wrote: Hi, all; I got a reply for my previous several postings saying that I was spamming the r-help mailing list. I am very sorry to all subscribers if I did that. But I've been reposting my message to the mailing list several times because I didn't know

Re: [R] book on regular expressions

2007-12-11 Thread hadley wickham
Could someone recommend a good book on regular expressions with focus on applications/use as it might relate to R. I remember there was a mention of such a reference book recently, but I could not locate that message on the archive. Mastering regular expressions by Jeffrey Friedl

Re: [R] book on regular expressions

2007-12-12 Thread hadley wickham
I don't think anyone has mentioned the references given on the help page ?regexp: they are a great deal more reliable than some of the third-party write-ups that have been mentioned. They are good technical references, but I don't think they're very helpful for someone trying to learn regular

Re: [R] two-way categorical anova post-hoc data extraction

2007-12-12 Thread hadley wickham
Hi list, I have a question regarding post-hoc extraction of data from a two-way categorical anova. I have a categorical anova of this form: width ~ steepness + patchiness (4 steepness levels, 4 patchiness levels) This simple setup answers if for the widths I collected across different

Re: [R] use ggplot in a function to which a column name is given

2007-12-13 Thread hadley wickham
Hi Jiho, The key to solving this problem is to use aes_string instead of aes. Instead of the complicated munging that aes does to get the names of the variables, aes_string works directly with strings, so that: aes_string(x = mpg, y = wt) == aes(x = mpg, y = wt) So your function would look

Re: [R] ggplot2: can not find current.grobTree()

2007-12-13 Thread hadley wickham
Is the function current.grobTree() implemented in ggplot2? According to the draft ggplot2 book, on page 43, we can get a list of all grobs with current.grobTree(). But when I try that, I get 'Error: could not find function current.grobTree'. Ooops - the book is now out of date. Paul Murrell

Re: [R] ggplot - Setting the y-scale in a bar plot

2007-12-13 Thread hadley wickham
PS: If you care to explain: why do all parameters in the code below have a . before the name, except precisely limits? I know it has to do with proto, but could not find out why this one was different. Not really - I started off with the convention that variables should start with a . to

Re: [R] use ggplot in a function to which a column name is given

2007-12-13 Thread hadley wickham
great! I knew you would have thought this through. That's perfect. As always there's the trade-off between writing code and documenting the code already written. In this case the trade-off turned toward the code part I guess. Autodetection of strings by aes would be even greater but that

Re: [R] Overlaying trellis xyplot on contourplot

2007-12-13 Thread hadley wickham
Hi Seth, An alternative would be to use ggplot2, http://had.co.nz/ggplot2: model - function(a,b,c,X1,X2) { (exp(a + b*X1 + c*X2)) / (1 + exp(a + b*X1 + c*X2)) } g - expand.grid(X1 = seq(0.40, 0.8,0.01), X2 = seq(0.03,0.99,0.03)) a - -37.61 b - 34.88 c - 28.44 g$z- model(a, b, c, g$X1,g$X2)

Re: [R] Changing the origin in polar.plot in plotrix package

2007-12-15 Thread hadley wickham
Hi John, One alternative would be to use ggplot2 with a polar coordinate system: library(ggplot2) qplot(mpg, wt, data=mtcars) + coord_polar() qplot(mpg, wt, data=mtcars, ylim=c(3,4)) + coord_polar() etc. You can see more examples of polar coordinates at

Re: [R] improving a bar graph

2007-12-16 Thread hadley wickham
On 12/16/07, Bob Green [EMAIL PROTECTED] wrote: Hello, Below is the code for a basic bar graph. I was seeking advice regarding the following: (a) For each time period there are values from 16 people. How I can change the colour value so that each person has a different colour, which

Re: [R] regression towards the mean, AS paper November 2007

2007-12-17 Thread hadley wickham
This has nothing to do really with the question that Troels asked, but the exposition quoted from the AA paper is unnecessarily confusing. The phrase ``Because X0 and X1 have identical marginal distributions ...'' throws the reader off the track. The

Re: [R] bar plot colors

2007-12-17 Thread hadley wickham
I have a question regarding colors in bar plots. I want to stack a total of 18 cost values in each bar. Basically, it is six cost types and each cost type has three components- direct, indirect, and induced costs. I would like to use both solid color bars and bars with the slanted lines

Re: [R] Reshape Dataframe

2007-12-18 Thread hadley wickham
On 12/18/07, Bert Jacobs [EMAIL PROTECTED] wrote: Hi, I'm having a bit of problems in creating a new dataframe. Below you'll find a description of the current dataframe and of the dataframe that needs to be created. Can someone help me out on this one? library(reshape) dfm - melt(df, id =

Re: [R] plotting magnitude

2007-12-18 Thread hadley wickham
On Dec 18, 2007 2:06 PM, [EMAIL PROTECTED] wrote: I am plotting fishing vessel positions and want these points to be relative in size to the catch at that point. Is this possible? I am just begining to use R and my search of the help section didnt help in this area. Heres what Im using so

Re: [R] New Cran Task View: ExperimentalDesign

2007-12-21 Thread hadley wickham
And the url is: http://cran.r-project.org/src/contrib/Views/ExperimentalDesign.html Hadley On 12/21/07, Ulrike Grömping [EMAIL PROTECTED] wrote: Dear UseRs, the new Task View ExperimentalDesign (Title: Design of Experiments (DoE) Analysis of Experimental Data) has just been uploaded to

Re: [R] Date formats

2007-12-30 Thread hadley wickham
On Dec 30, 2007 10:47 AM, Peter Dalgaard [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Read the warning in ?ifelse Yep. And, yes, it is annoying that ifelse() strips attributes, including class, but it is one of those things that have been in the S languages forever, and nobody really

Re: [R] reversing the scale on ggplot

2008-01-02 Thread hadley wickham
Hi Pedro, Sorry for missing this email - the good news is that in the next version of ggplot (hopefully coming out in the next few days), you'll be able to do: qplot(x, y, data=plotdata) + scale_x_reverse() qplot(x, y, data=plotdata) + scale_y_reverse() to get reversed scales Hadley On Oct

Re: [R] Confidence Inteval for regression curve.

2008-01-05 Thread hadley wickham
On Jan 5, 2008 7:45 PM, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote: Dear all, I have a dataset which I need to estimate the regression model and plot the estimated curve two other curves with low and high confidence interval (CI=95%). How can I do that? The easiest way is to use the

Re: [R] Cumulative sum of vector

2008-01-06 Thread hadley wickham
On Jan 5, 2008 8:32 AM, Keith Jones [EMAIL PROTECTED] wrote: Hi, Maybe I have not been looking in the right spot, but, I have not been able to fine a command to automatically calculate the running cumulative sum of a vector. Is there such a command? Try help.search(cumulative sum) Hadley

[R] Installing R on ubuntu dapper

2008-01-06 Thread hadley wickham
I followed the instructions at http://cran.r-project.org/bin/linux/ubuntu/README.html, but I'm getting the following error: ~: sudo apt-get install r-base Reading package lists... Done Building dependency tree... Done Some packages could not be installed. This may mean that you have requested an

Re: [R] Installing R on ubuntu dapper

2008-01-07 Thread hadley wickham
On 1/7/08, Emmanuel Charpentier [EMAIL PROTECTED] wrote: hadley wickham a écrit : I followed the instructions at http://cran.r-project.org/bin/linux/ubuntu/README.html, but I'm getting the following error: ~: sudo apt-get install r-base Reading package lists... Done Building

Re: [R] I need arguments pro-S-PLUS and against SAS...

2008-01-07 Thread hadley wickham
errors in the data usually because I know the data. I find errors because I can say things like library(Hmisc) datadensity(mydata) # show all raw data in small rug plots hist.data.frame(mydata) # postage-stamp size histograms of all variables in dataset latex(describe(mydata))

Re: [R] 4 dimensional graphics

2008-01-10 Thread hadley wickham
On Jan 10, 2008 8:36 AM, Petr PIKAL [EMAIL PROTECTED] wrote: Dear all I want to display 4 dimensional space by some suitable way. I searched CRAN and found miscellaneous 3 dim graphics packages which I maybe can modify but anyway I am open to any hint how to efficiently display data like:

Re: [R] Ceiling to the nearest ten?

2008-01-14 Thread hadley wickham
On 1/14/08, Jim Price [EMAIL PROTECTED] wrote: A suggestion for a family of such functions: ceilGenerator - function(num) function(x) num * ceiling(x / num) ceil10 - ceilGenerator(10) ceil20 - ceilGenerator(20) ceil10(1:10 * 4) ceil20(1:10 * 4) libraray(reshape)

Re: [R] Overlay plots from different data sets using the Lattice package

2008-01-14 Thread hadley wickham
On Jan 14, 2008 7:30 PM, Erin Steiner [EMAIL PROTECTED] wrote: #After spending the entire day working on this question, I have decided to reach out for support: #I am trying to overlay a densityplot from one data set over a histogram of another, if I were to plot the two individually, they

Re: [R] ggplot and spec.pgram

2008-01-15 Thread hadley wickham
Currently ggplot doesn't support any interactivity. What sort of interaction were you looking for with the periodogram? It might be possible to do something with rggobi. Hadley On Jan 15, 2008 10:38 AM, stephen sefick [EMAIL PROTECTED] wrote: Any Ideas to get an interactive periodogram? --

Re: [R] navigating ggplot viewports

2008-01-15 Thread hadley wickham
Hi Felix, I'm a bit stumped too - it's been a while since I've played around with viewports in ggplot. I have a feeling that this might be due to an old bug in grid that I thought had been fixed - you can't downViewport to a viewport underneath a frame grob. I've cc'd Paul in the hope that he

Re: [R] Overlay plots from different data sets using the Lattice package

2008-01-15 Thread hadley wickham
On Jan 15, 2008 12:27 PM, Dieter Menne [EMAIL PROTECTED] wrote: hadley wickham h.wickham at gmail.com writes: qplot(vals, ..density.., data = data.frame.A, geom=histogram, facets = factor.1 ~ factor.2, binwidth = 1) + geom_density(data=data.frame.B) uhh.. how should I understand y

Re: [R] Graphical output: dials and meters for a dashboard?

2008-01-15 Thread hadley wickham
I'm new to R and am evaluating it to see whether it would be an appropriate tool to create a dashboard (a graphical statistical summary page). Could someone tell me if it is possible to display data as dials or meters. e.g. the four dials here:

Re: [R] things that are difficult/impossible to do in SAS or SPSSbut simple in R

2008-01-17 Thread hadley wickham
Previously I used SAS for 23 years and now R/S-Plus for 17. SAS is effective for large datasets (in my work 500,000 subjects) but except for that, R is far superior to SAS for data management and manipulation. Just four of the reasons are that you can - merge data frames multiple ways

Re: [R] things that are difficult/impossible to do in SAS or SPSSbut simple in R

2008-01-17 Thread hadley wickham
Happy families are all alike; every unhappy family is unhappy in its own way. Leo Tolstoy and every messy data is messy in its own way - it's easy to define the characteristics of a clean dataset (rows are observations, columns are variables, columns contain values of consistent types). If you

Re: [R] Converting plots to ggplot2

2008-01-17 Thread hadley wickham
On Jan 17, 2008 9:53 AM, Thompson, David (MNR) [EMAIL PROTECTED] wrote: Hello Hadley, I am trying to reproduce the following with ggplot: a - seq(0, 360, 5)*pi/180 ; a ac - sin(a + (45*pi/180)) + 1 ; ac plot(a, ac, type='b', xaxt = n) axis(1, at=seq(0,6,1),

Re: [R] histogram with NAs

2008-01-18 Thread hadley wickham
Typical plots with vertical bars are not histograms. Consider barplot or plot(*, type = h) for such bar plots. . But no worry, I've mixed them up myself a number of times. Or you can use ggplot2, which will do the right thing regardless of whether you have continuous or categorical data:

Re: [R] image/area plot

2008-01-18 Thread hadley wickham
Do you have an example graphic that shows what you're trying to create? I can't figure out if you want something like a square pie chart (aka waffle chart), a stacked barchart, a levelplot, or something else. Hadley On Jan 18, 2008 6:06 AM, Marta Rufino [EMAIL PROTECTED] wrote: Dear R users,

Re: [R] things that are difficult/impossible to do in SAS or SPSSbut simple in R

2008-01-18 Thread hadley wickham
On Jan 18, 2008 1:19 PM, Jeffrey J. Hallman [EMAIL PROTECTED] wrote: Frank E Harrell Jr [EMAIL PROTECTED] writes: Rob Robinson wrote: I wonder if those who complain about SAS as a programming environment have discovered SAS/IML which provides a programming environment akin to Matlab

Re: [R] recoding one variable into another - but differently for different cases

2008-01-22 Thread hadley wickham
No one else mentioned this, but if those 99s represent missings, you should be using NA not a special numeric value. Hadley On Jan 22, 2008 5:40 PM, Dimitri Liakhovitski [EMAIL PROTECTED] wrote: Thanks a lot, everyone! Dimitri On 1/22/08, Gabor Grothendieck [EMAIL PROTECTED] wrote: Slight

Re: [R] help with levelplot()

2008-01-22 Thread hadley wickham
On Jan 22, 2008 8:39 PM, dxc13 [EMAIL PROTECTED] wrote: useR's, I want to create a movie of a sin function (from 0 to pi/2) using levelplot() in the lattice package. I basically want to create 20 or so plots of the sin function starting with an amplitude of 0 and ending at amplitude 1. By

Re: [R] Problem with geom_line

2008-01-23 Thread hadley wickham
On Jan 23, 2008 3:29 AM, Pilar Loren [EMAIL PROTECTED] wrote: Hi!, I need help, I have a problem with geom_line function because I have this error: df LENGTH LAT 091639 10.002 42.26282 091640 30.808 42.26834 091641 21.591 42.31689 091642 22.030 41.53246 091643 22.744

Re: [R] Barplot w/ single stacked bar

2008-01-24 Thread hadley wickham
I can reach my goal in ggplot2, although the relative heights of the bar's pieces don't seem quite right (it does generate a warning): library(ggplot2) x-factor(1) y-factor( c(Male,Male,Female) ) mydata - data.frame(x,y) rm(x,y) mydata Ooops! There was a bug in stat_bin that occurred

Re: [R] two histograms in the same graph

2008-01-25 Thread hadley wickham
On Jan 25, 2008 2:04 PM, Domenico Vistocco [EMAIL PROTECTED] wrote: You could use ggplot2: library(ggplot2) x=rnorm(100) y=rnorm(100) df=melt(data.frame(x,y)) #for vertical histogram ggplot(data=df,aes(x=value))+geom_histogram()+facet_grid(.~variable) #for horizontal histogram

Re: [R] using facet_grid() from ggplot2 with additional text in labels

2008-01-27 Thread hadley wickham
I am using ggplot2 at the moment and I must say it is definitely better then ggplot - good work. My problem is that I am using facet_grid() in the following way: p - ggplot(ssq, aes(x=year, y=-log(ssq))) p + geom_point() + facet_grid(me*gi~cs*rz) and it works nicely, except that I

Re: [R] Bug in levels() function?

2008-01-28 Thread hadley wickham
And subsetting a factor retains the original factor levels. To drop unused levels, just use factor(f[index]) or f[index, drop=TRUE]. The opposite behaviour can be even more annoying/dangerous because it leads to empty cells dropping out of tables and bars disappearing from barplots. Of course

Re: [R] using facet_grid() from ggplot2 with additional text in labels

2008-01-28 Thread hadley wickham
ggopt(strip.text = function(variable, value) paste(variable, value, sep== )) That's exactly what I was looking for - thanks. One thing that I should mention is that this is likely to change at some point in the future. Eventually it will become: + facet_grid(strip.text = function(variable,

Re: [R] [OT] vernacular names for circular diagrams

2008-01-28 Thread hadley wickham
On Jan 28, 2008 1:25 PM, Greg Snow [EMAIL PROTECTED] wrote: I had heard the same thing about Florence Nightingale, but it seems that this is a confusion of different graphs. Nightingale developed a graph based on a circle, but all the angles were equal and the different values were encoded

Re: [R] B-W stacked area chart with pattern

2008-01-29 Thread hadley wickham
On Jan 29, 2008 9:12 AM, Markus Didion [EMAIL PROTECTED] wrote: Dear all, I would like to create a stacked area chart to show the development of species biomass over time. Since it is intended for publication I need to prepare in black and white. I have tried to modify the stackedPlot

Re: [R] B-W stacked area chart with pattern

2008-01-30 Thread hadley wickham
On Jan 30, 2008 2:15 AM, Markus Didion [EMAIL PROTECTED] wrote: Thank you Greg for your comments. Here is a (very) simple example of what my data might look like: res - matrix(sample(20:25, 41*12, replace=T), nrow=12, ncol=41, dimnames=list(c(paste(sp,1:12)), c(seq(0, 200, by=5

Re: [R] adding text and other elements to ggplot2 plots

2009-03-11 Thread hadley wickham
Have a look at the annotations section of http://had.co.nz/ggplot2/book/toolbox.pdf Hadley On Wed, Mar 11, 2009 at 8:44 AM, levyofi levy...@post.tau.ac.il wrote: Hello, I really like the interface and flexibility of the ggplots package. However, I cannot find how to add text to a plot (like

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread hadley wickham
Thanks for the reply - some of the sets/palettes in the RColorBrewer are ideal, but the problem with the problem i have is that they only go up to 12 colours, and i need 15 colours - so i assume the only thing i can do is create my own palette, but i'm having limited success in trying to work

Re: [R] Unable to run smoother in qplot() or ggplot() - complains about knots

2009-03-13 Thread hadley wickham
On Thu, Mar 12, 2009 at 5:37 PM, Christopher David Desjardins cddesjard...@gmail.com wrote: I get the following error when I run qplot() qplot(grade, read,data = hhm.long.m, geom = c(point, smooth)) Error in smooth.construct.cr.smooth.spec(object, data, knots) :  x has insufficient unique

Re: [R] R-code in html help pages: syntax highlighting

2009-03-16 Thread hadley wickham
It would be pretty easy to use the output from the R parser (which is never wrong, is it?), and dump some markup out of it. For example the showTree function in codetools dumps an R expression as Lisp, this is not too far from generating html, or any other markup. As this sounds like fun,

Re: [R] - help - predicting with glmnet/lars for dataframes with different nrow then the train set

2009-03-16 Thread hadley wickham
On Mon, Mar 16, 2009 at 7:21 PM, eitan lavi lavi.ei...@gmail.com wrote: Hello I'm having trouble using lars and glmnet functions to predict on a new data set with different nrow then the original : for instance: =    log.1 = glm(temp.data$TL~(.),temp.data,family =

Re: [R] how to make aggregation in R ?

2009-03-19 Thread hadley wickham
On Thu, Mar 19, 2009 at 8:40 PM, jim holtman jholt...@gmail.com wrote: Try this technique.  I use it with large data objects since it is sometime faster, and uses less memory, by using indices: x - read.table(textConnection(  v1 v2 n1 n2 1   a a1  1 21 2   a a1  2 22 3   a a1  3 23 4   a

Re: [R] ggplot2: specifying legend titles

2009-03-20 Thread hadley wickham
On Fri, Mar 20, 2009 at 9:07 AM, Etches Jacob jetc...@iwh.on.ca wrote: I am trying to specify a legend title to be other than the variable name, but I find that the legend splits because scale_shape() takes effect but scale_colour() does not.  Can someone spot my error?  Here's some toy code

Re: [R] Retrieving Vertices Coordinates from SpatialPolygons

2009-03-21 Thread hadley wickham
This came up on R-sig-geo two days ago and this is what I said: I have the following code in ggplot2 for turning a SpatialPolygon into a regular data frame of coordinates. You'll need to load ggplot2, and then run fortify(yoursp). fortify.SpatialPolygonsDataFrame - function(shape, region =

Re: [R] Fisher test accuracy in doubt

2009-03-21 Thread hadley wickham
On Sat, Mar 21, 2009 at 2:03 PM, joker77 vijumo...@gmail.com wrote: Hi, I noted a discrepancy between R and openepi when I ran a fisher test with the same matrix. In R: a=matrix(c(1,2,6,17), nrow=2) a     [,1] [,2] [1,]    1    6 [2,]    2   17 fisher.test(a, conf.int=T)        

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