Re: [R] Is there a way force hiding of all messages when calling library()?

2011-12-21 Thread Hadley Wickham
You should be able to suppress them with suppressPackageStartupMessages() but not all packages produce startup messages in the approved manner. Hadley On Wed, Dec 21, 2011 at 5:36 PM, Saiwing Yeung wrote: > For example, if I call "library(spam)", I would get messages like this > > Package 'spam'

Re: [R] ggplot2: behaviour with empty datasets

2011-12-23 Thread Hadley Wickham
See https://github.com/hadley/ggplot2/issues/31 - I totally agree that it's annoying. Hadley PS. You are more likely to get helpful responses about ggplot2 on the ggplot mailing list. On Fri, Dec 23, 2011 at 7:08 AM, Casper Ti. Vector wrote: > For example, prepare like this >> df.0 <- data.fram

Re: [R] black and white in qplot? layout 4 graphs in one screen

2011-12-23 Thread Hadley Wickham
You might find the ggplot mailing list a friendlier place to ask questions about ggplot2. Hadley On Wed, Dec 21, 2011 at 2:16 PM, rachaelohde wrote: > Hello, > > I am trying to plot means and standard errors conditioned by a factor, using > qplot.  I am successful at getting the bar graph I want

Re: [R] Stacked area plot for time series

2011-12-23 Thread Hadley Wickham
You are more likely to get a helpful response if you provide a reproducible example - without that I can only guess that you need to use approx so you get y values at same x values. Hadley On Wed, Dec 21, 2011 at 8:13 AM, UncleFish wrote: > I wish to make a stacked area chart of a time series wi

Re: [R] cast in reshape and reshape2

2011-12-23 Thread Hadley Wickham
On Fri, Dec 23, 2011 at 1:58 PM, Kaiyin Zhong wrote: >> library(reshape2) >> x = melt(airquality, id=c('month', 'day')) > > With reshape I can cast with multiple functions: > >> library(reshape) >> cast(x, month+variable~., c(mean,sd)) >   month variable       mean         sd > 1      5    ozone  

Re: [R] cast in reshape and reshape2

2011-12-23 Thread Hadley Wickham
>> Have you looked at the .summarise argument to dcast? That seems to deliver >> the same sort of results one gets with base::aggregate. > > > Actually I see after looking at examples on the plyr-reshape-googlegroups > group that it is not '.summarise' but rather 'summarise'. Unfortunately > there

Re: [R] cast in reshape and reshape2

2011-12-26 Thread Hadley Wickham
>> ?plyr::summarise seems pretty helpful to me.  If you can do better, >> please submit a patch - they are very much appreciated. > > > My failure to find it stemmed from it not being mentioned in any way in > package reshape2's help files, but maybe I was mistaken that it was meant to > be used in

[R] [R-pkgs] Plyr 1.7

2011-12-30 Thread Hadley Wickham
# plyr plyr is a set of tools for a common set of problems: you need to __split__ up a big data structure into homogeneous pieces, __apply__ a function to each piece and then __combine__ all the results back together. For example, you might want to: * fit the same model each patient subsets of

[R] [R-pkgs] testthat 0.6

2011-12-30 Thread Hadley Wickham
# testthat Testing your code is normally painful and boring. `testthat` tries to make testing as fun as possible, so that you get a visceral satisfaction from writing tests. Testing should be fun, not a drag, so you do it all the time. To make that happen, `testthat`: * Provides functions that make

Re: [R] Applyiing mode() or class() to each column of a data.frame XXXX

2011-12-30 Thread Hadley Wickham
But be careful because class is a character vector (not necessarily a character vector of length 1) On Fri, Dec 30, 2011 at 10:21 AM, Justin Haynes wrote: > there is also colwise in the plyr package. > >> library(plyr) >> colwise(class)(data6) >      v13     v14       v15     f4     v16 > 1 integ

[R] Base function for flipping matrices

2011-12-31 Thread Hadley Wickham
Hi all, Are there base functions that do the equivalent of this? fliptb <- function(x) x[nrow(x):1, ] fliplr <- function(x) x[, nrow(x):1] Obviously not hard to implement (although it needs some more checks), just wondering if it had already been implemented. Hadley -- Assistant Professor / D

Re: [R] what's the command in R to completely clear the state of the console(including clearing up libraries, etc?)

2012-01-01 Thread Hadley Wickham
>> My understanding is that one only clears the variables... not >> functions/packages, etc... > > Not exactly true. rm should remove any function you defined in your current > session. You need to look at > > ?unloadNamespace > ?detach > > ...  in order to remove loaded packages. And read the cav

Re: [R] Base function for flipping matrices

2012-01-02 Thread Hadley Wickham
> But if not,  it seems to me that it should be added as an array method > to ?rev with an argument specifying which indices to rev() over. Yes, agreed. Sometimes arrays seem like something bolted onto R that is missing a lot of functionality. Hadley -- Assistant Professor / Dobelman Family Ju

Re: [R] Base function for flipping matrices

2012-01-02 Thread Hadley Wickham
> Your request is reminding me of the analysis of aray functions in Philip S > Abrams dissertation > http://www.slac.stanford.edu/cgi-wrap/getdoc/slac-r-114.pdf > AN APL MACHINE > > The section that starts on page 17 with this paragraph is the one that > immediately applies > > C. The Standard Form

Re: [R] Is it possible to "right align" text in R graphics?

2012-01-03 Thread Hadley Wickham
FYI, if you're looking for the technical term for this type of text it's bidi: http://en.wikipedia.org/wiki/Bi-directional_text Hadley On Tue, Jan 3, 2012 at 4:32 PM, Tal Galili wrote: > And I forgot to include the link to the image, here it is: > > http://dl.dropbox.com/u/5371432/right-to-left-

Re: [R] Quelplot

2011-09-22 Thread Hadley Wickham
x developed code for relplots and possibly > quelplots. > > Best Wishes, > Boris > > On Wed, Sep 21, 2011 at 3:11 PM, Hadley Wickham wrote: >> >> Hi all, >> >> Does anyone have an R implementation of the queplot (K. M. Goldberg >> and B. Iglewicz. Biv

Re: [R] remove NaN from element in a vector in a list

2011-09-27 Thread Hadley Wickham
>> apply(mt, 1, function(x) x[!is.nan(x)] ) > [[1]] > [1] 1 3 > > [[2]] > [1] 4 5 6 You need to be a little careful with apply: > mt2 <- matrix(c(1,4,2,5,3,6),2,3) > apply(mt2, 1, function(x) x[!is.nan(x)] ) [,1] [,2] [1,]14 [2,]25 [3,]36 Depending on the input you w

Re: [R] Question about ggplot2 and stat_smooth

2011-10-04 Thread Hadley Wickham
On Mon, Oct 3, 2011 at 12:24 PM, Thomas Adams wrote: >  I'm interested in creating a graphic -like- this: > > c <- ggplot(mtcars, aes(qsec, wt)) > c + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, alpha > = 0.2) > > but I need to show 2 sets of bands (with different shading) u

Re: [R] ggplot2: expression() in legend labels?

2011-10-04 Thread Hadley Wickham
You need to set the labels... Hadley On Sat, Sep 24, 2011 at 3:49 AM, Casper Ti. Vector wrote: > Is there any way to use expression() in legend labels with ggplot2? > > It seems that things like >> scale_shape_manual(value = c( >>   x = expression(italic(x)), >>   y = expression(italic(y)) >> ))

Re: [R] Question about ggplot2 and stat_smooth

2011-10-04 Thread Hadley Wickham
> # Function to compute quantiles and return a data frame > g <- function(d) { >   qq <- as.data.frame(as.list(quantile(d$y, c(.05, .25, .50, .75, .95 >   names(qq) <- paste('Q', c(5, 25, 50, 75, 95), sep = '') >   qq   } You could cut out the melt step by making this return a data frame: g <

Re: [R] multicore by(), like mclapply?

2011-10-10 Thread Hadley Wickham
On Mon, Oct 10, 2011 at 4:14 PM, Joshua Wiley wrote: > I could be waay off base here, but my concern about presplitting the data is > that you will have your data, and a second copy of our data that is something > like a list where each element contains the portion of the data for that > split.

Re: [R] Summary stats in table

2011-10-24 Thread Hadley Wickham
On Mon, Oct 24, 2011 at 5:39 AM, Duncan Murdoch wrote: > Suppose I have data like this: > > A <- sample(letters[1:3], 1000, replace=TRUE) > B <- sample(LETTERS[1:2], 1000, replace=TRUE) > x <- rnorm(1000) > > I can get a table of means via > > tapply(x, list(A, B), mean) > > and I can add the marg

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Hadley Wickham
>> So I was using the rshape package rather than rshape2.  I don't know the >> relationship between those two packages and/or how they differ.  I am sure >> that there are others that can help you out here. > >  I, too, don't know how the two packages 'reshape, The Orignal' and > 'reshape2, Reboote

Re: [R] any updates w.r.t. lapply, sapply, apply retaining classes

2011-11-03 Thread Hadley Wickham
>    In the example I give above, the impact might seem small, but the > implications are *huge*.  This means that I am, in effect, not allowed to > use *any* of the vectoring functions in 'R', which avoid performing loops > thereby speeding up process time extraordinarily.  Many can sympathize tha

Re: [R] any updates w.r.t. lapply, sapply, apply retaining classes

2011-11-03 Thread Hadley Wickham
>    I agree that it is non-trivial to solve the cases you & I have posed. >  However, I would wholeheartedly support having an error spit back for any > function that does not explicitly support a class.  In this case, if I > attempt to do   sapply(x, class), and 'x' is of class "difftime", then I

[R] [R-pkgs] devtools 0.6

2012-03-03 Thread Hadley Wickham
# devtools The aim of `devtools` is to make your life as a package developer easier by providing R functions that simplify many common tasks. Devtools is opinionated about how to do package development, and requires that you use `roxygen2` for documentation and `testthat` for testing. Future versi

Re: [R] Improving help in R

2012-03-17 Thread Hadley Wickham
> One difficulty in getting the help pages to look beautiful is that the > original input is so inconsistent, and package authors (naturally) get upset > when CRAN starts rejecting packages because of errors that used to be > ignored.  The current output is definitely a compromise aimed at making m

Re: [R] Year of data collection for 'diamonds' dataset in ggplot2

2012-03-27 Thread Hadley Wickham
I believe it was 2008. Hadley On Mon, Mar 26, 2012 at 11:46 AM, Marina Doucerain wrote: > Hello, > > I'm wondering what was the year (or year range) of collection for the data > included in the 'diamonds' dataset in ggplot2. > This information would be very helpful in interpreting the 'price' var

Re: [R] Appropriate method for sharing data across functions

2012-04-05 Thread Hadley Wickham
Why not pass around a reference class? Hadley On Thu, Apr 5, 2012 at 3:20 PM, John C Nash wrote: > In trying to streamline various optimization functions, I would like to have > a scratch pad of working data that is shared across a number of functions. > These can be called from different levels

Re: [R] Appropriate method for sharing data across functions

2012-04-09 Thread Hadley Wickham
> Make OPCON an environment and pass it into the functions that may read it or > alter it.  There > is no real need to pass it out, since environments are changed in-place > (unlike lists).  E.g., >  > x <- list2env(list(one=1, two="ii", three=3)) >  > x >   >  > objects(x) >  [1] "one"   "three"

Re: [R] Faceted bar plot shows wrong counts (ggplot2)

2012-04-11 Thread Hadley Wickham
And it's now fixed in the dev version. Hadley On Tue, Mar 13, 2012 at 11:37 AM, Helios de Rosario wrote: > Michael, > > Thanks for the pointer to the discussion in the ggplot list. It seems > that the reason of this behaviour of facet_grid() is already known and > being discussed by the developer

Re: [R] geom_plot creates Area Instead Of Lines

2012-04-11 Thread Hadley Wickham
> What I would have liked is something like a cloud of lines, similar to what > I get when I convert the data into a matrix (why do I not just use a matrix? > I come from MATLAB and this seems natural, however, my data is large and a > data frame seems to be an advantageous way to handle that). It

Re: [R] extend data frame for plotting heat map in ggplot2

2012-04-11 Thread Hadley Wickham
On Sun, Apr 1, 2012 at 9:16 AM, Till Bayer wrote: > Hi all! > > I want to generate a heat map from an all-vs-all comparison. I have the > data, already scaled to 0-1. However, I have the values only for the > comparisons in one way, and not for the comparisons between the same group > (which are a

Re: [R] Aggregate by minimum

2012-01-10 Thread Hadley Wickham
On Mon, Jan 9, 2012 at 8:00 PM, jim holtman wrote: > try this: > >> x <- structure(list(speed = c(3,9,14,8,7,6), result = c(0.697, 0.011, 0.015, >> 0.012, 0.018, 0.019), house = c(1, > + 1, 1, 1, 1, 1), date = c(719, 1027, 1027, 1027, 1030, 1030), > +    id = c("1000", "1", > +    "10001", "1

Re: [R] parallel computation in plyr 1.7

2012-01-16 Thread Hadley Wickham
Please see https://github.com/hadley/plyr/issues/60 Hadley On Thu, Jan 12, 2012 at 11:54 AM, abhagwat wrote: > The code below shows that > (1) the way to activate the parallel backend indeed is to use 'registerDoMC' > (2) the function d_ply does NOT accept the argument parallel, while the > funct

Re: [R] list: index of the element, that is TRUE

2012-01-16 Thread Hadley Wickham
On Mon, Jan 16, 2012 at 10:15 AM, Duncan Murdoch wrote: > On 12-01-16 10:34 AM, Marion Wenty wrote: >> >> Dear People, >> >> I have got the following example for a vector and the index of the TRUE >> element: >> >> Myvector<- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) >> which(Myvector) >>

Re: [R] ggplot- using geom_point and geom_line at the same time

2012-01-17 Thread Hadley Wickham
On Mon, Jan 16, 2012 at 6:05 PM, Mary Kindall wrote: > Thanks for reply > I wanted to have legend name with spaces. Right now I am using the > following code but it produce two legends. I have to use Gimp to cut the > redundant legend. Your basic problem is that you're using the fill and colour a

Re: [R] New PLYR issue

2012-01-17 Thread Hadley Wickham
> Note that although ddply does a lot for you, it doesn't reproduce all of > your calculations on all of the data columns like summaryBy does... you have > to explicitly create every calculated column in your function. Well, ddply doesn't, but colwise will. Hadley -- Assistant Professor / Dobel

Re: [R] What is a 'closure'?

2012-01-19 Thread Hadley Wickham
On Thu, Jan 19, 2012 at 1:45 PM, Ajay Askoolum wrote: > The "R Language Definition" at > http://cran.r-project.org/doc/manuals/R-lang.html states in the following > section > > 4.3.2 Argument matching > This subsection applies to closures but not to primitive functions. > > What are 'closures'?

Re: [R] Subsetting for the ten highest values by group in a dataframe

2012-01-28 Thread Hadley Wickham
On Fri, Jan 27, 2012 at 1:26 PM, Sam Albers wrote: > Hello, > > I am looking for a way to subset a data frame by choosing the top ten > maximum values from that dataframe. As well this occurs within some > factor levels. > > ## I've used plyr here but I'm not married to this approach > require(ply

Re: [R] ggplot2(0.9.0): could not find function "=="

2012-02-01 Thread Hadley Wickham
Hi James, There were a few problems with the 0.9.0 version, which is why it was pulled from CRAN. I'd recommend re-installing 0.8.9: install.packages("ggplot2", type = "source") Hadley On Wed, Feb 1, 2012 at 2:10 PM, J Toll wrote: > Hi, > > I have a question related to the newest version of gg

Re: [R] nice report generator?

2012-02-06 Thread Hadley Wickham
> 2. It's more flexible to construct the language object as a language object, > rather than pasting something together and parsing it.  For one thing, that > allows non-syntactic variable names; I think it's also easier to read.  So > your code > > txt<- paste("tabular(value*v*", LEFT , "~" ,RIGHT

Re: [R] ggplot2(0.9.0): could not find function "=="

2012-02-07 Thread Hadley Wickham
> I'm curious if you have a guess whether the issue I was having is a > result of the "problems" with the 0.9.0 version or if they're due to > fundamental changes in ggplot2? It looks like a bug - I'll add it to the to do list. Hadley -- Assistant Professor / Dobelman Family Junior Chair Depart

Re: [R] Version control (git, mercurial) for R packages

2012-02-09 Thread Hadley Wickham
> Same warning here. Which made me think that R CMD build will probably > tar up the git repository along with the package, which is not > something I would like to do, and which CRAN people most likely won't > tolerate in a package on CRAN. It doesn't. And you can always use .Rbuildignore to ign

Re: [R] Version control (git, mercurial) for R packages

2012-02-09 Thread Hadley Wickham
>> I'm exploring using a version control system to keep better track >> of changes to the packages I maintain. I'm leaning towards git >> (although mercurial also looks good) but am not sure what is the >> best way to set up the repository. It seems I can't set the >> repository directly within the

Re: [R] ggplot using scale_x_date gives Error in seq.int(r1$year, to$year, by)

2012-02-10 Thread Hadley Wickham
Hi Aidan, str is your friend: > str(g) 'data.frame': 9 obs. of 3 variables: $ Date: chr "2011-12-23" "2011-12-30" "2012-01-06" "2011-12-23" ... $ variable: Factor w/ 3 levels "Price","Yield",..: 1 1 1 2 2 2 3 3 3 $ value : num 86.78 86.04 86.44 9.74 9.54 ... You haven't turned the

Re: [R] GGplot controlling point size across range

2012-02-10 Thread Hadley Wickham
On Thu, Jan 12, 2012 at 5:27 PM, Darran King wrote: > Hi all > > New to R and GGplot2 but loving the potential. I am trying to plot four > separate point plots by looping over the data and plotting a different > subset each time. > > When I plot the data as a point plot, the size of the points is

Re: [R] pretty(range(data$z),10) Error

2012-02-10 Thread Hadley Wickham
Hi Mario, If you're still having problems, I'd suggest sending a small reproducible example (https://github.com/hadley/devtools/wiki/Reproducibility) to the ggplot2 mailing list. Hadley On Tue, Jan 17, 2012 at 12:32 PM, Mario Giesel wrote: > Hello, R-List, > I'm getting error messages when addi

Re: [R] Plotting bar graph over a geographical map

2012-02-10 Thread Hadley Wickham
Hi Simon, You might want to try sending a small reproducible example (https://github.com/hadley/devtools/wiki/Reproducibility) to the ggplot2 mailing list. Hadley On Tue, Jan 31, 2012 at 10:53 PM, sjlabrie wrote: > Hi, > > I am looking for a way to plot bar on a map instead of the standard poin

Re: [R] ggplot2 geom_polygon fill

2012-02-10 Thread Hadley Wickham
Hi Raimund, To increase your chances of getting help, I'd recommend using the ggplot2 mailing list, and reducing your example down to the essence of the problem. For example, the theme components don't affect the problem, but make the code longer, and so harder to understand. Hadley On Mon, Feb

Re: [R] nice report generator?

2012-02-10 Thread Hadley Wickham
>> To be strictly correct, shouldn't that be: >> >> formula<- eval(substitute( value*v*LEFT ~ RIGHT, list(LEFT=LEFT, >> RIGHT=RIGHT))) >> >> ? > > > I think it probably doesn't matter.  The difference is that mine gives a > pure language object, whereas yours gives a formula object.  The formula >

Re: [R] assigning NULL to a list element

2012-02-18 Thread Hadley Wickham
On Fri, Feb 17, 2012 at 7:51 PM, Benilton Carvalho wrote: > Hi everyone, > > For reasons beyond the scope of this message, I'd like to append a > NULL element to the end of a list. > > tmp0 <- list(a=1, b=NULL, c=3) > append(tmp0, c(d=4)) ## works as expected > append(tmp0, c(d=NULL)) ## list with

Re: [R] introducing R to high school students

2012-04-18 Thread Hadley Wickham
> Now I have to put my money where my mouth is. I've offered to visit a > high school and introduce R to some fairly advanced students > participating in a longitudinal 3-year science research class. > > I anticipate keeping things very simple: > --objects and the fact that there is stuff inside th

Re: [R] introducing R to high school students

2012-04-18 Thread Hadley Wickham
> If the students are in a "science research" class, does that mean they > have data from their own research that they would want to understand > better?  I think that would be much more motivating than anything else. It might depends on the class - most high school science experiments aren't that

Re: [R] trouble loading ggplot2 using R

2012-04-24 Thread Hadley Wickham
> I have a similar error, running R in Snow Leopard too > >> library("ggplot2") > Error : .onAttach failed in attachNamespace() for 'ggplot2', details: >  call: stats::runif(1) >  error: .Random.seed no es un vector de números enteros pero es de tipo > 'list' > Error: package/namespace load failed

Re: [R] trouble loading ggplot2 using R

2012-04-25 Thread Hadley Wickham
On Wed, Apr 25, 2012 at 6:27 AM, Ramon Ovelar wrote: > I don't think I have touched at anything at all. I'm very newbie to R and to > be honest I don't know what "Ramdom.seed" is. I will try to find out. > > I have seen other messages about "restoring random.seed", but in order to > check that the

[R] R development master class: NYC June 21-22, Bay Area June 28-29

2012-05-21 Thread Hadley Wickham
Hi all, I'm going to be teaching an R development master classes in NYC June 21-12 and in the Bay Area June 28-29. The basic idea of the class is to help you write better code, focused on the mantra of "do not repeat yourself". In day one you will learn powerful new tools of abstraction, allowing

Re: [R] marginality principle / selecting the right type of SS for an interaction hypothesis

2008-05-25 Thread hadley wickham
> BTW, although I didn't read it carefully, the your web-page description of a > main effect in the presence of an interaction appears to imply that this > averages across all individuals, when in fact it averages across the levels > of the other factor; the result is different when there are unequ

Re: [R] transforming output of grid.locator() to coordinates of a leaf viewport

2008-06-01 Thread hadley wickham
Ben, What if the click occurs over multiple viewports? Hadley On Mon, Jun 2, 2008 at 6:50 AM, Wittner, Ben, Ph.D. <[EMAIL PROTECTED]> wrote: > Short form: > >How do I transform the output of grid.locator() (or > grid.locator(unit='npc')) to the native (or npc) coordinates of a vi

Re: [R] label outliers in geom_boxplot (ggplot2)

2008-06-05 Thread hadley wickham
2008/5/27 Mihalicza Péter <[EMAIL PROTECTED]>: > Dear List and Hadley, > > I would like to have a boxplot with ggplot2 and have the outlier values > labelled with their "name" attribute. So I did > > library(ggplot2) > > dat=data.frame(num=rep(1,20), val=c(runif(18),3,3.5), > name=letters[1:2

Re: [R] ggplot questions

2008-06-05 Thread hadley wickham
On Wed, Jun 4, 2008 at 2:03 PM, Thompson, David (MNR) <[EMAIL PROTECTED]> wrote: > Hello, > > A few questions about the following examples: > 1. Why do the two plotting versions not produce the same result? Because version one has two layers, and version two has one? > 2. Is the 'scale_x_continuo

Re: [R] label outliers in geom_boxplot (ggplot2)

2008-06-06 Thread hadley wickham
> It's too obvious, so I am positive that there is a good reason for not doing > this, but still: > why is it not possible, to have an "outlier" output in stat_boxplot that can > be used at geom_text()? > > Something like this, with "upper": > > dat=data.frame(num=rep(1,20), val=c(runif(18),3,3.5

Re: [R] ggplot questions

2008-06-06 Thread hadley wickham
> Does the difference have something to do with ggplot() using ranges > derived from the data? > When I modify my original 'test' dataframe with two extra rows as > defined below, I get expected results in both versions. Order shouldn't matter - and if it's making a difference, that's a bug. But

Re: [R] Improving data processing efficiency

2008-06-06 Thread hadley wickham
On Fri, Jun 6, 2008 at 5:10 PM, Daniel Folkinshteyn <[EMAIL PROTECTED]> wrote: > Hmm... ok... so i ran the code twice - once with a preallocated result, > assigning rows to it, and once with a nrow=0 result, rbinding rows to it, > for the first 20 quarters. There was no speedup. In fact, running wi

Re: [R] color scale mapped to B/W

2008-06-06 Thread hadley wickham
On Fri, Jun 6, 2008 at 3:37 PM, Michael Friendly <[EMAIL PROTECTED]> wrote: > In an R graphic, I'm using > > cond.col <- c("green", "yellow", "red") > to represent a quantitative variable, where green means 'OK', yellow > represents 'warning' > and red represents 'danger'. Using these particular co

Re: [R] Improving data processing efficiency

2008-06-06 Thread hadley wickham
>> > install.packages("profr") >> Warning message: >> package 'profr' is not available > > I selected a different mirror in place of the Iowa one and it > worked. Odd, I just assumed all the same packages are available > on all mirrors. The Iowa mirror is rather out of date as the guy who was loo

Re: [R] color scale mapped to B/W

2008-06-06 Thread hadley wickham
On Fri, Jun 6, 2008 at 6:23 PM, Achim Zeileis <[EMAIL PROTECTED]> wrote: > On Fri, 6 Jun 2008, Michael Friendly wrote: > >> In an R graphic, I'm using >> >> cond.col <- c("green", "yellow", "red") >> to represent a quantitative variable, where green means 'OK', yellow >> represents 'warning' >> and

Re: [R] lsmeans

2008-06-07 Thread hadley wickham
On Sat, Jun 7, 2008 at 3:02 PM, John Fox <[EMAIL PROTECTED]> wrote: > Dear Dieter, > > I don't know whether I qualify as a "master," but here's my brief take on > the subject: First, I dislike the term "least-squares means," which seems to > me like nonsense. Second, what I prefer to call "effect d

Re: [R] lsmeans

2008-06-08 Thread hadley wickham
On Sun, Jun 8, 2008 at 12:58 PM, Douglas Bates <[EMAIL PROTECTED]> wrote: > On 6/7/08, John Fox <[EMAIL PROTECTED]> wrote: >> Dear Dieter, >> >> I don't know whether I qualify as a "master," but here's my brief take on >> the subject: First, I dislike the term "least-squares means," which seems t

Re: [R] lsmeans

2008-06-08 Thread hadley wickham
> Well put Doug. I would add another condition, which I don't know how to > state precisely. The settings for the other terms, which are usually > marginal medians, modes, or means, must make sense when considered jointly. > Frequently when all adjustment covariates are set to overall marginal m

Re: [R] Frame from long to wide format

2008-06-10 Thread hadley wickham
The reshape package will definitely do what you want. Cast will automatically fill in an missing spots with NAs, and you'll just need something like the following for your aggregation function: last <- function(x) x[length(x)] You can find out more about reshape at http://had.co.nz/reshape Hadl

Re: [R] model simplification using Crawley as a guide

2008-06-11 Thread hadley wickham
On Wed, Jun 11, 2008 at 6:42 AM, Frank E Harrell Jr <[EMAIL PROTECTED]> wrote: > ChCh wrote: >> >> Hello, >> >> I have consciously avoided using step() for model simplification in favour >> of manually updating the model by removing non-significant terms one at a >> time. I'm using The R Book by M

Re: [R] Subset in cast: compact form?

2008-06-12 Thread hadley wickham
On Thu, Jun 12, 2008 at 2:27 PM, Agustin Lobo <[EMAIL PROTECTED]> wrote: > Hi! > > How can I subset several variables in cast? > > For example, I can do it for one, (ie, ph): > cast(am, organismo +arriba ~ variable,subset=variable=="ph",mean,na.rm=T) > > For selecting ph, temperature and Ba I'm usi

[R] Wanted: your examples of logged axes with custom tick marks

2008-06-13 Thread hadley wickham
Dear all, I'm trying to improve the default layout of tick marks for log scaled axes in ggplot2. To this end, it would be really useful to see what people actually do in practice. If you've ever made a log-log (or semi-log) plot and customised the location of the ticks, I'd really appreciate a c

Re: [R] help with colsplit (reshape)

2008-06-13 Thread hadley wickham
> M.Data2 <- data.frame(M.Data, colsplit(M.Data$variable, split = "\\.", names > = c("treatment", "time"))) > > which gave: > > head(M.Data2) > pid variable value treatment time > 1 1predA-1 predA predA > 2 2predA-2 predA predA > 3 3predA-1 predA predA >

Re: [R] help with colsplit (reshape)

2008-06-13 Thread hadley wickham
> Right, there is no time associated with this variable. So I tried again, > treating it as an id: > > M.Data <- melt(Data, id = c("pid", "predA")) > > From here I was able to achieve the desired result, as follows: > > M.Data <- data.frame(M.Data, colsplit(M.Data$variable, split = "\\.", > names=c

Re: [R] alternative to matching/merge?

2008-06-13 Thread hadley wickham
On Fri, Jun 13, 2008 at 11:45 AM, jim holtman <[EMAIL PROTECTED]> wrote: > What is the structure of 'd.frame' and 'segFile'? Run Rprof so that > we can see which of the functions it is spending its time in. What > happens if x$index is not in seqFile$index? Are the values in the > 'index' unique

Re: [R] overlaid transparent histograms

2008-06-13 Thread hadley wickham
> Three questions: > 1a) Why does the following code not produce transparent bars? Because you're setting the fill colour (not mapping it to a variable in your dataset), the fill needs to be outside of aes() g + geom_histogram(aes(x=log(BNCw)), fill = alpha("red", .5)) + geom_histogram(aes(x=l

[R] strsplit, keeping delimiters

2008-06-13 Thread hadley wickham
Hi all, Does anyone have a version of strsplit that keeps the string that is split by. e.g. from x <- "A: 123 B: 456 C: 678" I'd like to get c("A:", "123 ", "B: ", "456 ", "C: ", 678) but strsplit(x, "[A-Z]+:") gives me c("", " 123 ", " 456 ", " 678") Any ideas? Thanks, Hadley -- http://

Re: [R] strsplit, keeping delimiters

2008-06-14 Thread hadley wickham
On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this: > >> library(gsubfn) >> x <- "A: 123 B: 456 C: 678" >> strapply(x, "[^ :]+[ :]|[^ :]+$") > [[1]] > [1] "A:" "123 " "B:" "456 " "C:" "678" > > and check out the gsubfn home page at: > > http://gsubfn.go

Re: [R] strsplit, keeping delimiters

2008-06-14 Thread hadley wickham
On Sat, Jun 14, 2008 at 10:20 AM, Martin Morgan <[EMAIL PROTECTED]> wrote: > "hadley wickham" <[EMAIL PROTECTED]> writes: > n >> On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck >> <[EMAIL PROTECTED]> wrote: >>> Try this: >>> >

Re: [R] Creating a Hash from Data.Frame

2008-06-15 Thread hadley wickham
On Sun, Jun 15, 2008 at 9:03 PM, jim holtman <[EMAIL PROTECTED]> wrote: > here is a way: > >> x <- read.table(textConnection("#GDS_ID GENE_NAME GENE_DESCRIPTION >> GENE_FUNCTION > + 1007_s_at | DDR1 | discoidin domain receptor tyrosine kinase 1 | > protein-coding > + 1053_at | RFC2 | replication f

Re: [R] ggplot2: How to remove legend component for geom_errorbar() ?

2008-06-16 Thread hadley wickham
Hi Carsten, In my eagerness to get every component of the legend working automatically, I've completed neglected a way to turn bits off of you don't want them (the philosophy is that every geom that uses an aesthetic should appear in the legend in some way). The best thing I can suggest at the mo

Re: [R] sizing non-vector point shapes in ggplot2

2008-06-16 Thread hadley wickham
On Mon, Jun 16, 2008 at 7:52 AM, mfrumin <[EMAIL PROTECTED]> wrote: > > Dear all, > > With normal plotting, one can size a set of points in a plot using a vector > argument to cex in the points() function. This works whether you are using > one of the standard R symbols (i.e. 19+) or some ascii sy

Re: [R] sizing non-vector point shapes in ggplot2

2008-06-16 Thread hadley wickham
> Thanks for getting back to me so quickly. This mostly works, in that: > > - When I ran it just as you sent it, I get this error: > Error in inherits(x, "factor") : object "fill" not found Oh yeah, that's a change in the development version. > - but when I took out "fill = fill" from your s

Re: [R] ggplot2: How to remove legend component for geom_errorbar() ?

2008-06-16 Thread hadley wickham
> thanks for your tip! It worked fine (though I had to use "tile" instead > of "point"). I see your point to handle legends the way you do, which is > a very convenient feature of ggplot. It's great for points, lines, bars > etc., but in the particular case of error bars, I think it would be > reas

Re: [R] Accessing Max/Min Value of Density Function

2008-06-16 Thread hadley wickham
>> mydensity <- density(x) >> print(mydensity) > > x y > Min. : -92.14 Min. :0.000e+00 > 1st Qu.: 356.66 1st Qu.:5.530e-09 > Median : 805.45 Median :4.681e-05 > Mean : 805.45 Mean :5.564e-04 > 3rd Qu.:1254.24 3rd Qu.:3.370e-04 > Max. :1703.04 Max.

Re: [R] ggplot facet spacing, wrapping

2008-06-17 Thread hadley wickham
On Tue, Jun 17, 2008 at 5:54 AM, mfrumin <[EMAIL PROTECTED]> wrote: > > I'm running into some problems with the spacing of some faceted ggplot plots. > I have a number of time series faceted to be one above another, but the > scale labels of the y axes all clobber each other at the bottom/top of ea

Re: [R] Reshape or Stack? (To produce output as columns)

2008-06-17 Thread hadley wickham
On Tue, Jun 17, 2008 at 5:59 AM, Steve Murray <[EMAIL PROTECTED]> wrote: > > Dear all, > > I have used 'read.table' to create a data frame of 720 columns and 360 rows > (and assigned this to 'Jan'). The row and column names are numeric: > >> columnnames <- sprintf("%.2f", seq(from = -179.75, to =

Re: [R] re sultant column names from reshape::cast, with a fun.aggregate vector

2008-06-17 Thread hadley wickham
> I would think that something like this would fix it up, but no dice: > > cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, num.neg = > function(x) sum(x < 0))) > > that is, why not look at names(fun.aggregate)? or am I missing something? Yes, that's a bug in each (the function which

Re: [R] Using the shape () function

2008-06-17 Thread hadley wickham
On Tue, Jun 17, 2008 at 9:28 AM, Tom Backer Johnsen <[EMAIL PROTECTED]> wrote: > In a research project we are using a web-based tools for collecting data > from questionnaire. The system generates files that are simple to read as a > data frame in the "long" format, which are simple to convert to

Re: [R] A new task view on survival analysis

2008-06-17 Thread hadley wickham
And here's the link: http://cran.r-project.org/web/views/Survival.html Hadley On Tue, Jun 17, 2008 at 12:33 PM, Arthur Allignol <[EMAIL PROTECTED]> wrote: > Dear all, > > A new task view on survival analysis > is now online. > It attempts to deal with all the R-packages > that permit to analyze t

Re: [R] Reshape or Stack? (To produce output as columns)

2008-06-17 Thread hadley wickham
On Tue, Jun 17, 2008 at 1:47 PM, Steve Murray <[EMAIL PROTECTED]> wrote: > > Dear all, > > Many thanks for the suggestions put forward. I've decided to go with the > 'melt' command from the 'reshape' library, as this seems to run the quickest. > > I do have a couple of questions however, regarding

Re: [R] Using the shape () function

2008-06-17 Thread hadley wickham
>> You might try using the reshape package instead: >> >> last <- function(x) x[length(x)] >> names(d) <- c("value", "person", "time") >> cast(d, person ~ time, last) > > The first and the last line I think is clear, although I will have to > experiment more to understand the call on cast () better

Re: [R] Reshape or Stack? (To produce output as columns)

2008-06-17 Thread hadley wickham
>> It sounds like something is going wrong with the melting. Could you >> please include the output of str(original data frame), and >> str(melted)? (Or even better a small version of your data created >> with dput) > > And this is a str output of the original data frame (first few rows of that >

Re: [R] How to create strata out of the data.frame table

2008-06-18 Thread hadley wickham
On Wed, Jun 18, 2008 at 9:20 AM, Ana Kolar <[EMAIL PROTECTED]> wrote: > My data.frame table consist of 3 variables (x,y and z) where each variable > has 1000 units. I need to create 5 equal size strata according to one of the > variable (let's say x) whereas units of x variable with a higher value

Re: [R] computing the average and standard deviation for many sets of triplicates, using "R-approach"

2008-06-18 Thread hadley wickham
On Wed, Jun 18, 2008 at 9:17 AM, Daren Tan <[EMAIL PROTECTED]> wrote: > > Below example has 4 sets of triplicates, without using for loop and > iteratively cbind the columns, what is the "R-approach" of generating a > matrix of 8 columns that are the averages and standard deviations ? The > aver

Re: [R] help with manipulating data frames (survey analysis)

2008-06-18 Thread hadley wickham
> I want to do statistical analysis on some survey data and I can specify what > I would like to do very easily in algorithmic terms. However, being a n00b > to R I am struggling with getting R to execute what I want. > > I think all I need is some source that directs me in the right direction by >

Re: [R] Controlling the length of line with abline(lm())

2008-06-19 Thread hadley wickham
On Wed, Jun 18, 2008 at 9:09 PM, Tariq Perwez <[EMAIL PROTECTED]> wrote: > Hi > I just realized that when I use linear regression to draw a line through my > data points with something like the following: > > abline(lm(y ~ x)) > > > the length of the line is infinite, i.e., the line goes beyond the

Re: [R] R web site-Useability & finding varous bits of documentation

2008-06-19 Thread hadley wickham
> Note that the R-project page (www.r-project.org) > and CRAN are two "things", albeit closely related. > CRAN is for "DOWNLOAD"ing, including free contributed docs. > So that is the main reason, "contrib.docs" are not there in the > www.r-project.org sidebar. Why does there need to be two site

<    4   5   6   7   8   9   10   11   12   13   >