Re: [R] Is a list an atomic object? (or is there an issue with the help page of ?tapply ?)

2017-02-15 Thread Hadley Wickham
It seems like this should be consistent with split(), since that's what actually powers the behaviour. Reading the description for split leads to this rather interesting example: tapply(mtcars, 1:11, I) Hadley On Tue, Feb 14, 2017 at 7:10 PM, Hervé Pagès wrote: > Hi, > > tapply() will work on

Re: [R] Is a list an atomic object? (or is there an issue with the help page of ?tapply ?)

2017-02-20 Thread Hadley Wickham
On Mon, Feb 20, 2017 at 7:31 AM, Martin Maechler wrote: >> Hervé Pagès >> on Tue, 14 Feb 2017 17:10:05 -0800 writes: > > > Hi, tapply() will work on any object 'X' that has a length > > and supports single-bracket subsetting. These objects are > > sometimes called "vector-

Re: [R] Confused about using data.table package,

2017-02-20 Thread Hadley Wickham
On Sun, Feb 19, 2017 at 3:01 PM, David Winsemius wrote: > >> On Feb 19, 2017, at 11:37 AM, C W wrote: >> >> Hi R, >> >> I am a little confused by the data.table package. >> >> library(data.table) >> >> df <- data.frame(w=rnorm(20, -10, 1), x= rnorm(20, 0, 1), y=rnorm(20, 10, 1), >> z=rnorm(20, 20

Re: [R] Histogram with two colors depending on condition

2008-07-17 Thread hadley wickham
On Thu, Jul 17, 2008 at 5:13 PM, Mohammad Ehsanul Karim <[EMAIL PROTECTED]> wrote: > Dear List, > > Say, we generate data like this- > > dat<-rnorm(1000,1,2) > hist(dat) library(ggplot) qplot(dat, geom="histogram", colour = factor(dat < 0)) Hadley -- http://had.co.nz/

Re: [R] Matching Up Values

2008-07-17 Thread hadley wickham
On Fri, Jul 18, 2008 at 5:09 AM, Rolf Turner <[EMAIL PROTECTED]> wrote: > > On 18/07/2008, at 8:42 AM, Steve Murray wrote: > > > >> So what I'm looking to do is, 'pad out' the shorter file, by adding in the >> rows with those that are 'missing' from the longer file (ie. if a particular >> c

Re: [R] size and coding error in plot ?

2008-07-17 Thread hadley wickham
On Fri, Jul 18, 2008 at 9:44 AM, <[EMAIL PROTECTED]> wrote: > Hello R users: > > I was trying to draw a boxplot?using 2 variables (rain and wind). Both of > them has length 25056. So dummy is a matrix with dimension 2 x 25056. First I > tried to draw a full boxplot using the following code?and g

Re: [R] smooth.spline

2008-07-19 Thread hadley wickham
On Fri, Jul 18, 2008 at 10:15 PM, Roland Rau <[EMAIL PROTECTED]> wrote: > Spencer Graves wrote: >> >> I found the first chapter of Paul Dierckx (1993) Curve and Surface Fitting >> with Splines (Oxford U. Pr.). Beyond that, I've learned a lot from the >> 'fda' package and the two companion volumes

Re: [R] Sum efficiently from large matrix according to re-occuring levels of factor?

2008-07-20 Thread hadley wickham
On Sun, Jul 20, 2008 at 4:16 PM, Ralph S. <[EMAIL PROTECTED]> wrote: > > Hi, > > I am trying to calculate the sum for each occurrence of the level of a factor > in a very large matrix. In addition, I want to save that sum together with > the information of the level of the factor and the level of

Re: [R] Sum efficiently from large matrix according to re-occuring levels of factor?

2008-07-20 Thread hadley wickham
On Sun, Jul 20, 2008 at 4:47 PM, hadley wickham <[EMAIL PROTECTED]> wrote: > On Sun, Jul 20, 2008 at 4:16 PM, Ralph S. <[EMAIL PROTECTED]> wrote: >> >> Hi, >> >> I am trying to calculate the sum for each occurrence of the level of a >> factor in a v

Re: [R] TeachingDemos question: my.symbols() alignment problems in complicated layout

2008-07-20 Thread hadley wickham
> Here are a couple of options: > > (i) use the 'gridBase' package and do these arrow annotations using the > 'grid' package, which allows you to control coordinate systems in a more > rational manner. There's an example (perhaps slightly more complicated > than you need) in: > http://cran.r-proj

Re: [R] Lattice Version of grconvertX or variant on panel.text?

2008-07-20 Thread hadley wickham
On Sun, Jul 20, 2008 at 6:03 PM, Bryan Hanson <[EMAIL PROTECTED]> wrote: > Still playing with Lattice... > > I want to use panel.text(x, y etc) but with x and y in plot coordinates > (0,1), not user coordinates. > > I think if I had this problem with traditional graphics, I could use > grconvertX t

Re: [R] Sum efficiently from large matrix according to re-occuring levels of factor?

2008-07-21 Thread hadley wickham
orresponding entry, and then record the result of that. >>> >>> Any idea? >>> >>> Best, >>> >>> Ralph >>> >>> >>> >>> >>>> Date: Sun, 20 Jul 2008 16:50:

Re: [R] scatter plot using ggplot

2008-07-22 Thread hadley wickham
On Tue, Jul 22, 2008 at 3:42 AM, Megh Dal <[EMAIL PROTECTED]> wrote: > I used ggplot to create a scatter plot : > > library(ggplot) > library(mnormt) > Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2) > x = rmnorm(20, c(0,0), Sigma) > xx = x[order(x[,1]),] > y = xx[,1] > z = xx[,2] > qplot(z, y, type="point

Re: [R] Plotting Multiple lines on one plot

2008-07-23 Thread hadley wickham
The easiest way to do with this ggplot2 is to melt your data first: dfm <- melt(df, id = "date", measure = c("theta","vega","delta")) qplot(date, value, data=dfm, geom="line", colour = variable) Hadley On Tue, Jul 22, 2008 at 6:05 PM, R_Learner <[EMAIL PROTECTED]> wrote: > > Hi, > I'm trying to

Re: [R] ggplot question

2008-07-24 Thread hadley wickham
On Thu, Jul 24, 2008 at 2:23 AM, Williams Scott <[EMAIL PROTECTED]> wrote: > I am trying to do something simple with ggplot. I wish to draw a density > plot split by group, and fill each group with a different colour (and > each with an alpha =0.25). I have tried a number of variations of the > fol

Re: [R] melting a list: basic question

2008-07-25 Thread hadley wickham
On Fri, Jul 25, 2008 at 9:49 AM, baptiste auguie <[EMAIL PROTECTED]> wrote: > Dear list, > > > I'm trying to use the reshape package to perform a merging operation on a > list of data.frames as illustrated below, > >> a <- 1:10 >> example <- list( data.frame(a=a, b=sin(a)), data.frame(a=a, b=cos(a

Re: [R] melting a list: basic question

2008-07-25 Thread hadley wickham
On Fri, Jul 25, 2008 at 8:50 PM, hadley wickham <[EMAIL PROTECTED]> wrote: > On Fri, Jul 25, 2008 at 9:49 AM, baptiste auguie <[EMAIL PROTECTED]> wrote: >> Dear list, >> >> >> I'm trying to use the reshape package to perform a merging operation on a

Re: [R] melting a list: basic question

2008-07-27 Thread hadley wickham
> Is it possible to install your development version of reshape? I could not > find it alongside of ggplot2 on github. Not yet, but I'm working on it. > If not, I've added "..." in the > method for the current version and it seems to work for me. Yes, that's the exact change I made. Thanks! Ha

Re: [R] A easy way to write formula

2008-07-27 Thread hadley wickham
On Sun, Jul 27, 2008 at 4:19 AM, Mark Difford <[EMAIL PROTECTED]> wrote: > > Hi Jinsong and Thierry, > >>> (x1 + x2 + x3) ^2 will give you the main effects and the interactions. > > Although it wasn't specifically requested it is perhaps important to note > that (...)^2 doesn't expand to give _all_

Re: [R] Is there anyway to clip the bottom of a barplot?

2008-07-28 Thread hadley wickham
That's probably not a good idea. See the end of this article for some reasons why and an alternative: http://www.b-eye-network.com/view/2468 Hadley On Mon, Jul 28, 2008 at 11:23 PM, Arthur Roberts <[EMAIL PROTECTED]> wrote: > Hi, all, > > I need to show only values in a barplot from say 4-12. W

Re: [R] R command history -- can it be like Matlab's?

2008-07-29 Thread hadley wickham
On Tue, Jul 29, 2008 at 2:45 PM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > A patch to do this was posted on 2007-09-29 by Glenn Davis. Some people not > addicted to Matlab find the behaviour very inconvenient and prefer the > getline/readline behaviour (triggered by ^R/^S) of Rterm and R on U

Re: [R] R command history -- can it be like Matlab's?

2008-07-29 Thread hadley wickham
On Tue, Jul 29, 2008 at 4:39 PM, Rolf Turner <[EMAIL PROTECTED]> wrote: > > On 30/07/2008, at 9:16 AM, hadley wickham wrote: > >> On Tue, Jul 29, 2008 at 2:45 PM, Prof Brian Ripley >> <[EMAIL PROTECTED]> wrote: >>> >>> A patch to do this wa

Re: [R] bug in 'margins' behavior in reshape - cast

2008-07-30 Thread hadley wickham
On Wed, Jul 30, 2008 at 11:47 AM, mfrumin <[EMAIL PROTECTED]> wrote: > > according to the documentation of the cast function in the reshape function, > I would expect this bit of code from the examples to calculate marginal > means over only the 'diet' variable. > > #Chick weight example > names(Ch

Re: [R] bug in 'margins' behavior in reshape - cast

2008-07-30 Thread hadley wickham
On Wed, Jul 30, 2008 at 12:41 PM, mfrumin <[EMAIL PROTECTED]> wrote: > > I want the column that is never going to actually have the '(all)' level to > not become of type factor. continuing the example: > > chick_m$diet = as.integer(as.character(chick_m$diet)) > is.factor(chick_m$diet) #returns FAL

Re: [R] bug in 'margins' behavior in reshape - cast

2008-07-31 Thread hadley wickham
On Thu, Jul 31, 2008 at 4:59 AM, Michael Frumin <[EMAIL PROTECTED]> wrote: > thanks, that workaround, well, works! > > what are you working on with the rewrite? just efficiency? or major > changes in functionality/interface? I've come up with a strategy that makes reshape _much_ faster - 10-20x

Re: [R] History pruning

2008-07-31 Thread hadley wickham
> It's not really equivalent, natural language has ambiguities and subtleties > that computer languages, especially functional languages, intentionally > don't have. By their nature, computer languages can be turned into parse > trees unambiguously and then those trees can be manipulated. But in

Re: [R] FW: Bubble plots

2008-08-02 Thread hadley wickham
On Sat, Aug 2, 2008 at 8:10 AM, Frank E Harrell Jr <[EMAIL PROTECTED]> wrote: > Cody Hamilton wrote: >> >> Is there a way to create a 'bubble plot' in R? >> >> For example, if we define the following data frame containing the level of >> y observed for 5 patients at three time points: >> >> time<-c

Re: [R] FW: Bubble plots

2008-08-02 Thread hadley wickham
On Sat, Aug 2, 2008 at 1:41 PM, John Fox <[EMAIL PROTECTED]> wrote: > Dear Cody, Frank, and Hadley, > > Perhaps a more general point is that using a vectorized cex argument to > plot() or points(), one can specify the relative radii of circles. > > Try, for example, plot(1:10, cex=sqrt(1:10)). Of

Re: [R] RE SHAPE package question.

2008-08-02 Thread hadley wickham
On Sat, Aug 2, 2008 at 4:00 PM, hpdutra <[EMAIL PROTECTED]> wrote: > > I am sorry but here is an example >> test > t1 t2 t3 t4 M F id > 1 1 0 0 0 1 0 1 > 2 1 0 0 0 1 0 1 > 3 1 0 0 0 0 1 1 > 4 1 0 1 1 1 0 1 > 5 1 0 1 1 1 0 1 > 6 1 0 1 1 1 0 1 > 7 1 0 1 1 0 1 1 > >

Re: [R] RE SHAPE package question.

2008-08-02 Thread hadley wickham
missing: using 'F:\Users\Kevin\Documents/R/win-library/2.7' > Warning message: > package 'SHAPE' is not available > > Is it called something else? > > Kevin > > hadley wickham <[EMAIL PROTECTED]> wrote: >> On Sat, Aug 2, 2008 at 4:00 PM,

Re: [R] RESHAPE cast help.

2008-08-05 Thread hadley wickham
On Tue, Aug 5, 2008 at 11:59 AM, <[EMAIL PROTECTED]> wrote: > I have a set of data that is basically sales figures for a given year. It has > columns for Yeaqr, Day Of Year, Sku, SubCatetory, and Category. The first few > lines of data look like: > Year DayOfYearSku Quantity CatId

Re: [R] boxplot with average instead of median

2008-08-05 Thread hadley wickham
On Mon, Aug 4, 2008 at 10:36 PM, Chad Junkermeier <[EMAIL PROTECTED]> wrote: > I really like the ease of use with the boxplot command in R. I would rather > have a boxplot that shows the average value and the standard deviation then > the median value and the quartiles. I would suggest that you d

Re: [R] lattice: add vertical lines in xyplot

2008-08-07 Thread hadley wickham
> Alternatively, I tried in ggplot but here again, I get an error: > >> p <- ggplot(my.df, aes(x, y)) + >>geom_path(aes(colour = fact)) + >>facet_grid(fact2 ~ fact) + >> geom_vline(intercept = my.lines) # how do I select the >> relevant one ? If you want a d

Re: [R] Reshape set operations?

2008-08-10 Thread hadley wickham
Hi Kevin, I think easiest way would be to create a single dataset with both years in, and then work from that: t2008$year <- 2008 t2007$year <- 2007 tall <- rbind(t2007, t2008) mall <- melt(tall, id.var=c("DayOfYear","Category","SubCategory","Sku", "year"), measure.var=c("Quantity") cast(mall,

Re: [R] ggplot2 font size problem

2008-08-11 Thread hadley wickham
Hi dhzdhz, There's currently no particularly easy way to do this. It is possible to use grid to edit these labels directly (see http://had.co.nz/ggplot2/book/grid.pdf), but the next version of ggplot2 will have a more convenient theming system that will make it much easier to make these sorts of

Re: [R] ggplot2 font size problem

2008-08-11 Thread hadley wickham
On Mon, Aug 11, 2008 at 1:24 PM, dhzdhz <[EMAIL PROTECTED]> wrote: > > x=c("abcdefghijklmn", "opqrstuvwxyz") > y=c(1, 2) > df=data.frame(name=x, value=y) > p=ggplot(df, aes(name, value))+geom_point() > grid.gedit(gPath("xaxis"), gp=gpar(fontsize=8)) > print(p) > > It doesn't work. I have to print(p

Re: [R] ggplot2: remove minor-horizontal guide before drawing

2008-08-14 Thread hadley wickham
Hi Paul, Unfortunately, the book is a bit ahead of the current version of ggplot2 code, and it's a bit of pain to do in the 0.6 code. Your best bet is to have a look at grid.grab to capture the grob before it is drawn. In the development version the new theming support lets completely turn off m

Re: [R] Graphing: plot 3rd variable based on color gradient

2008-08-14 Thread hadley wickham
On Thu, Aug 14, 2008 at 2:30 PM, Jason Pare <[EMAIL PROTECTED]> wrote: > Hello, > > I am searching for the best method to plot two variables with points > whose output color depends on the size of a third variable. For > example, the darkness of the x-y point would increase incrementally > based on

Re: [R] continuous coloring of a polygon

2008-08-15 Thread hadley wickham
It rather sounds like you might be designing a gauge display for a dashboard. If that's the case, I'd recommend checking out: Information Dashboard Design: The Effective Visual Communication of Data Stephen Few http://www.amazon.com/dp/0596100167 as well as some of his online writings: http://w

Re: [R] Multiple Plotting help (lines don't always connect)

2008-08-18 Thread hadley wickham
On Mon, Aug 18, 2008 at 3:54 PM, Rolf Turner <[EMAIL PROTECTED]> wrote: > > On 19/08/2008, at 1:04 AM, stephen sefick wrote: > >> The real data are counts of aquatic insects at distinct locations on a >> river continuum on the way down a river, so the when a point point on >> the graph is missing

Re: [R] Multiple Plotting help (lines don't always connect)

2008-08-18 Thread hadley wickham
>> Doesn't a line plot inherently display a set of linear interpolations? > > Yes. And your point is? > > Compare: > > x <- 1:10 > y <- rep(1:2,5) > y[5] <- NA > y0 <- approx(x,y,xout=1:10) > plot(y0,type="l") > > with > > foo(x,y) > > where > > foo <- function(x,y,...) { > plot(x,y,type="n",...)

Re: [R] Simple estimate of a probability by simulation

2008-08-20 Thread hadley wickham
On Wed, Aug 20, 2008 at 7:56 AM, Alberto Monteiro <[EMAIL PROTECTED]> wrote: > > Jaap Van Wyk wrote: >> >> I would appreciate any help with the following. >> Problem: Suppose A, B and C are independent U(0,1) random variables. >> What is the probability that A(x^2) + Bx + C has real roots? I have >

[R] [ANN] ASA Data expo 09 - Airline on-time performance

2008-08-21 Thread hadley wickham
Dear all, Have you ever been stuck in an airport because your flight was delayed or cancelled and wondered if you could have predicted it if you'd had more data? This is your chance to find out. I'd like to let you know about the American Statistical Association's Data Expo 09. This year's chall

Re: [R] sd(NA)

2008-08-22 Thread hadley wickham
Here's one approach: try_default <- function(expr, default = NA, quiet = FALSE) { result <- default if (quiet) { tryCatch(result <- expr, error = function(e) {}) } else { try(result <- expr) } result } failwith <- function(default = NULL, f, quiet = FALSE) { function(...) try_

[R] Building colorspace on RHEL5

2008-08-22 Thread hadley wickham
Dear all, I'm having problems installing the colorspace package on Red Hat Enterprise Linux 5: * Installing *source* package 'colorspace' ... ** libs gcc -std=gnu99 -I/usr/lib/R/include -I/usr/lib/R/include -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fs

Re: [R] ggplot facet: change layout of panels

2008-08-23 Thread hadley wickham
Hi Tom, Not yet, but I'm working on it for the next version. Regards, Hadley On Sat, Aug 23, 2008 at 10:08 AM, Tom Boonen <[EMAIL PROTECTED]> wrote: > Hi, > > is there anyway to adjust how ggplot(facet=) displays the layout of > panels? I have a dataset with many 25 groups and gplot(y,x,facet=

Re: [R] graphs for pretest data

2008-08-23 Thread hadley wickham
On Sat, Aug 23, 2008 at 1:10 PM, Michael Kubovy <[EMAIL PROTECTED]> wrote: > Dear Juliet, > > Perhaps start here: > > require(lattice) > mwpp <- data.frame(y = c(43,42,26,39,60,60,46,40,41,36,42,54, >58,43,46,56,81,56,70,70,44,52,81,59,69,68), >sex = rep(c(rep('men', 14), rep('women

Re: [R] ggplot boxplot - how to order categories

2008-08-25 Thread hadley wickham
Hi Raj, It's the same as the other plotting systems in R: you need to change the order of the underlying factor levels. e.g.: levels(diamonds$color) <- c("J", "D", "E", "I", "H", "F", "G") If you're reordering then according to the value of another variable, also see ?reorder Hadley On Mon, A

Re: [R] ggplot scale_size - is there any way to specify breaks?

2008-08-25 Thread hadley wickham
> Is there any way to specify a range to scale_size()? There is an option > called "breaks" in scale_size_identity() that does what I want. Is there > something similar for scale_size()? Not in the released version, but there is in the development version - all scales now take a limits argument wh

Re: [R] Mosaic plot using ggplot2

2008-08-25 Thread hadley wickham
> I would like to know if mosaic plots are supported by ggplot2? If so, > can someone point me to a couple of examples or give me any pointers? Not yet, although I have some plans for them, they're at least 6 months away. Hadley -- http://had.co.nz/ __

Re: [R] embedded examples

2008-08-26 Thread hadley wickham
You might also want to look at existing visualisation applications that connect with R: * http://ggobi.org * http://rosuda.org/mondrian * http://rosuda.org/software/Gauguin/gauguin.html to name a few. Hadley On Tue, Aug 26, 2008 at 10:31 AM, EBo <[EMAIL PROTECTED]> wrote: > > I am working on

Re: [R] A Tip: lm, glm, and retained cases

2008-08-26 Thread hadley wickham
On Tue, Aug 26, 2008 at 6:45 PM, Ted Harding <[EMAIL PROTECTED]> wrote: > Hi Folks, > This tip is probably lurking somewhere already, but I've just > discovered it the hard way, so it is probably worth passing > on for the benefit of those who might otherwise hack their > way along the same path. >

Re: [R] juxtaposed and stacked bars in one barplot?

2008-08-27 Thread hadley wickham
Hi Stefan, Could you be a bit more explicit? Do you have an example dataset that you are trying to visualise? Hadley On Wed, Aug 27, 2008 at 4:38 AM, Stefan Uhmann <[EMAIL PROTECTED]> wrote: > Hi, > > anybody any hints how to get a barplot with both juxtaposed and stacked > bars? > > /Stefan >

Re: [R] Calculating total observations based on combinations of variable values

2008-08-27 Thread hadley wickham
On Wed, Aug 27, 2008 at 12:11 PM, Josip Dasovic <[EMAIL PROTECTED]> wrote: > Hello: > > As someone making the move from STATA to R, I'm finding it difficult at times > to perform basic tasks in R, so forgive me if I've missed an obvious and > easily obtained solution to my problem. I've searche

Re: [R] Updating a list.

2008-08-27 Thread hadley wickham
On Wed, Aug 27, 2008 at 6:18 PM, <[EMAIL PROTECTED]> wrote: > I have a list that is generated from the resape package function 'cast'. It > consists of three columns, Sku, DayOfYear, variable it is generated like: > > r2007 <- cast(m2008, DayOfYear ~ variable | Sku, sum) > > Now DayOfYear can ran

Re: [R] juxtaposed and stacked bars in one barplot?

2008-08-28 Thread hadley wickham
On Thu, Aug 28, 2008 at 9:31 AM, Stefan Uhmann <[EMAIL PROTECTED]> wrote: > hadley wickham schrieb: >> >> Hi Stefan, >> >> Could you be a bit more explicit? Do you have an example dataset that >> you are trying to visualise? >> > > Right, thanks

[R] Density estimates in modelling framework

2008-08-29 Thread hadley wickham
Hi all, Do any packages implement density estimation in a modelling framework? I want to be able to do something like: dmodel <- density(~ a + b, data = mydata) predict(dmodel, newdata) This isn't how sm or KernSmooth or base density estimation works. Are there other packages that do density e

Re: [R] Free SQL Database with R

2008-09-02 Thread hadley wickham
sqlite But for a sensible answer, you need to define what you mean by best. Hadley On Tue, Sep 2, 2008 at 8:16 AM, Chibisi Chima-Okereke <[EMAIL PROTECTED]> wrote: > Hi all, > > could someone tell me which is the best user-friendly free/open source sql > database system to use with R, particular

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 Yu wrote: > Hi, > > There are quiet a few different 'apply' func

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 Bolker wrote: > >  just a quick question (to which I suspect the answer is "no"): > does anyone know if, in the gg

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 Bolker 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" argument)

Re: [R] Plyr and memory allocation issue

2009-08-18 Thread hadley wickham
Hi Simeon, That's weird. Could you please send me a reproducible example off-list? Hadley On Tue, Aug 18, 2009 at 1:21 AM, simeon duckworth wrote: > Dear R users > > I am trying to create some new variables for a 4401 x 30 dataframe using > ddply and transform.  The "id" variable i am using is

Re: [R] ggplot2 legend problem

2009-08-19 Thread hadley wickham
On Tue, Aug 18, 2009 at 11:10 PM, Chris Friedl 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 <- data.frame(

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 permie wrote: > Dear R users, > > I have a matrix a and a classification vector b such that > >

[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] 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_2555 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??" where Tony Plate recommende

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 Boulinguiez wrote: > Sorry I forgot the code that goes with > > **CODE > desorb_plot<-ggplot() + > >        geom_smooth(data=DATA.B1

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 wa

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
> In the spirit of "less is more", I find the underscores to be distracting > and unneeded typing.  Just simplify to camel caps. This is just personal style. If you right your own style guide you can change it ;) Hadley -- http://had.co.nz/ __ R-hel

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 gr

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

Re: [R] Transform data for repeated measures

2009-08-28 Thread hadley wickham
On Thu, Aug 27, 2009 at 6:37 PM, Richardson, Patrick 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   2.50   2.30   2.14   2

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

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 Sorkin wrote: > For my money, and perspective as one who has written a compiler, this > reflects a failing of the

Re: [R] Sapply

2009-08-30 Thread hadley wickham
On Sun, Aug 30, 2009 at 5:08 PM, Noah Silverman 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 "group" of which th

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 https:/

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 Leynes 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 the > archives. >

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 Kubovy wrote: > Hi Stephen, > > Because coord_trans() does all the work of plotting the original values on > the tranformed scale. See ?coord_trans. To quote: "The

Re: [R] Andrews plot

2009-09-07 Thread hadley wickham
On Mon, Sep 7, 2009 at 8:36 AM, Petr PIKAL 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 if there is any >

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, rafamoral 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 bars > > Thanks! > > Raf

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 =

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 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 instance: > > ex

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(

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

2009-09-15 Thread hadley wickham
On Tue, Sep 15, 2009 at 9:48 AM, ivo welch 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) NA } )   #

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

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 post

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 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) >> >> attach(vc

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

2009-09-21 Thread hadley wickham
>> From: hadley wickham >> >> 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 difficu

Re: [R] Need help on boxplot panel chart

2010-02-15 Thread hadley wickham
Hi Doug, Could you please provide a reproducible example? It's difficult to diagnose the problem without one. Hadley On Fri, Feb 12, 2010 at 2:46 PM, DougNiu wrote: > > Hi there: > > I am new to R and creating a boxplot panel chart to show a test result. > > I have four output variables (OV1,

Re: [R] argh .. if/else .. why?

2010-02-15 Thread hadley wickham
> I, personally, utilize the ifelse(test,statement,statement) function when > possible over the methodology outlined. if + else and ifelse perform quite different tasks, and in general can not (and should not) be exchanged. In particular, note that for ifelse, "the class attribute of the result

Re: [R] Problems with boxplot in ggplot2:qplot

2010-02-15 Thread hadley wickham
Hi Dimitri, Have you looked at the examples for scale_x_date - http://had.co.nz/ggplot2/scale_date.html? They show you how to both set the limits and control the labels. Hadley On Sun, Feb 14, 2010 at 1:34 PM, Dimitri Shvorob wrote: > > ... Unfortunately, a problem remains: I cannot label x ti

Re: [R] Problems with boxplot in ggplot2:qplot

2010-02-15 Thread hadley wickham
Without a reproducible example, it's impossible to give you any more suggestions. Hadley On Mon, Feb 15, 2010 at 2:16 PM, Dimitri Shvorob wrote: > > Trying > > + scale_x_date(format = "%b") > > produces a peculiar result: Apr and Dec facets are labeled "Jan", remaining > labels are blank. > -- >

[R] [R-pkgs] ggplot2: version 0.8.6

2010-02-19 Thread Hadley Wickham
ggplot2 ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (l

Re: [R] How to use a 'hidden' function directly?

2010-02-24 Thread hadley wickham
Try: stats:::R_pansari Hadley On Wed, Feb 24, 2010 at 7:55 PM, Dale Steele wrote: > Thanks, when I modify the function as I think you suggest, I get the > following error: > > qansari  <- function(p, m, n) { >                .C("R_qansari", as.integer(length(p)), q = as.double(p), >            

Re: [R] ggplot2 : bug in coord_equal() ?

2010-02-26 Thread hadley wickham
Hi David, That's the behaviour I'd expect - the plot is 5 x 13000. What were you expecting? Hadley On Fri, Feb 26, 2010 at 8:06 AM, David Hajage wrote: > Hello, > > I think there is a bug in coord_equal when x s a factor : > > ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar() > ggplot(diam

Re: [R] two questions for R beginners

2010-03-01 Thread hadley wickham
> One of the things about R which many (and that certainly includes > me) have to find out the hard way is that you have to *learn* > what to expect! You can't just import it from prior experience in > other contexts. So, by the time you have learned that a matrix > is such that all its elements mu

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