Re: [R] the first and last observation for each subject

2009-01-02 Thread hadley wickham
On Fri, Jan 2, 2009 at 3:20 AM, gallon li wrote: > I have the following data > > ID x y time > 1 10 20 0 > 1 10 30 1 > 1 10 40 2 > 2 12 23 0 > 2 12 25 1 > 2 12 28 2 > 2 12 38 3 > 3 5 10 0 > 3 5 15 2 > . > > x is time invariant, ID is the subject id number, y is changing over time. > > I want

Re: [R] ggplot: adding layer using different data, groups and also controlling appearance

2008-12-31 Thread hadley wickham
t; legend. Thanks! > > On Wed, Sep 24, 2008 at 8:03 PM, hadley wickham wrote: >> On Wed, Sep 24, 2008 at 7:57 PM, wrote: >>> >>> >>> I have a more complicated function I am trying to write, but I run in to a >>> problem when I want to >&g

Re: [R] Componentwise means of a list of matrices?

2008-12-30 Thread hadley wickham
> naturally > divided into pieces: the elements of the list. For this reason, the l*ply > functions don't > need an argument that describes how to break up the data structure. > > (from: plyr: divide and conquer, Hadley Wickham 2008) > > Perhaps a new case to conside

Re: [R] Merge or combine data frames with missing columns

2008-12-29 Thread hadley wickham
Or even more simply: On Mon, Dec 29, 2008 at 12:17 PM, Henrique Dallazuanna wrote: > Try this: > > do.call(rbind, lapply(l, "[", unique(unlist(sapply(l, names) > > Where "l" is your list. Or even more simply: library(plyr) do.call(rbind.fill, l) which doesn't get the variable order quite r

Re: [R] ggplot2 Xlim

2008-12-26 Thread hadley wickham
Hi Felipe, It sounds like ForkLength is a factor - what deos str(FL) tell you? You might also need geom_bar(..., stat = "identity") since your data are pretabulated. Hadley On Fri, Dec 26, 2008 at 2:44 PM, Felipe Carrillo wrote: > Wayne: > What's crowded are my x axis labels. The bars look fine

Re: [R] ggplot2's qplot() not rendering title descender

2008-12-23 Thread hadley wickham
Hi Mike, Yup, that's a bug that will be fixed in the next version. In the meantime one easy fix is to add an \n on the end of the title string. Hadley On Tue, Dec 23, 2008 at 7:02 PM, Mike Lawrence wrote: > On my machine (Mac OS 10.5.6, R 2.8.1) the following plot is drawn such that > a substa

Re: [R] Summary information by groups programming assitance

2008-12-22 Thread hadley wickham
On Mon, Dec 22, 2008 at 7:15 PM, Ranney, Steven wrote: > Thank you all for your help. I appreciate the assistance. I'm thinking I > should have been more specific in my original question. > > Unless I'm mistaken, all of the suggestions so far have been for maximum vol > and maximum Length by La

Re: [R] Summary information by groups programming assitance

2008-12-22 Thread hadley wickham
On Mon, Dec 22, 2008 at 3:51 PM, Ranney, Steven wrote: > All - > > I have data that looks like > > psd Species Lake Length WeightSt.weightWr > Wr.1 vol > 432 substock SMB Clear150 41.00 0.01 95.12438 > 95.10118 0.0105 > 433 substock SMB Clea

Re: [R] diagonal lines in legends of ggplot2

2008-12-19 Thread hadley wickham
Hi Erich, Can you explain why you don't want them? The philosophy behind the legend code is to attempt to match the appearance of the geoms in the plot as closely as possible. There are a few exceptions, like this diagonal line, where the legends are slightly different to make it easier to see c

Re: [R] Programmatically minimising main R window (on windows)

2008-12-16 Thread hadley wickham
On Tue, Dec 16, 2008 at 5:40 PM, Prof Brian Ripley wrote: > On Tue, 16 Dec 2008, hadley wickham wrote: > >> Hi all, >> >> Is it possible to programmatically minimise the main window of the >> windows R gui? I'm designing a small gui with gwidgets & RGtk2 fo

[R] Programmatically minimising main R window (on windows)

2008-12-16 Thread hadley wickham
Hi all, Is it possible to programmatically minimise the main window of the windows R gui? I'm designing a small gui with gwidgets & RGtk2 for an non-statistician to use, and it would be nice if I could easily hide all the R stuff that they don't need. Thanks, Hadley -- http://had.co.nz/

Re: [R] opening a PDF document

2008-12-14 Thread hadley wickham
On Sun, Dec 14, 2008 at 6:18 PM, Dennis Fisher wrote: > Colleagues, > > I am interesting in opening a PDF document via the command line from both > Windows, OS X, and Linux ( R version 2.8.0). I found a command openPDF in > Biobase. However, I would rather execute the command myself. For exampl

[R] [R-pkgs] New version of ggplot2, 0.8.1

2008-12-14 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] Some clarificatins of anova() and summary ()

2008-12-14 Thread hadley wickham
> anyone please explain why this happens.. I know this happens when x1 > and x2 has different sizes. but here x1 and x2 have same dimension. Given that this is a homework problem, I think the onus is on you to figure this out, not on us to help you. In almost all classes, you are expected to work

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 3:08 PM, Vitalie Spinu wrote: > On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham > wrote: > > >>> or may be just >>> mtcars[cyl>3&last(20)] >>> >>> or this is already too far? >> >> This would be a con

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
> My end would be the output of your end(). If there are no args and no local > context, I don't see the need for it to be a function call. It would just > be defined as something like > > end <- structure( function(n) c(rep(FALSE, n-1), TRUE), class="selector") Oh, I see what you mean. > I'm n

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
>> Oh yes, that's a good point. But wouldn't the following do the job? >> >> "&.selector" <- function(a, b) { >> function(n) a(n) & b(n) >> } >> >> or >> >> "&.selector" <- function(a, b) { >> function(n) intersect(a(n), b(n)) >> } >> >> depending on whether selectors return logical or numeric v

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 11:11 AM, Vitalie Spinu wrote: > On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham > wrote: > >> You could also imagine similar iterators for random sampling, like >> samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80% >> with r

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch wrote: > On 12/12/2008 11:38 AM, hadley wickham wrote: >> >> On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch >> wrote: >>> >>> On 12/12/2008 8:25 AM, hadley wickham wrote: >>>>> >>>&

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch wrote: > On 12/12/2008 8:25 AM, hadley wickham wrote: >>> >>> From which you might conclude that I don't like the design of subset, and >>> you'd be right. However, I don't think this is a countere

Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
> From which you might conclude that I don't like the design of subset, and > you'd be right. However, I don't think this is a counterexample to my > general rule. In the subset function, the select argument is treated as an > unevaluated expression, and then there are rules about what to do with

Re: [R] ref card for data manipulation?

2008-12-11 Thread hadley wickham
>> You (as many before you) have overlooked the ave() function, which can >> replace the ordering as well the do.call(c,tapply()) >> > > Majority of questions on this list concern data manipulation. Many are > repetitive. "Overlooking" like that will always happen unless some > comprehensive da

Re: [R] repeated searching of no-missing values

2008-12-10 Thread hadley wickham
> Perhaps... But plyr works only on **basic** data structures, and I referred > to all **possible** data strucures (deliberately); so I stand by my > statement and note that you did not contradict it. To me the basic structures are vectors, matrices and arrays; lists; and data frames (that these a

Re: [R] repeated searching of no-missing values

2008-12-10 Thread hadley wickham
> graphics,statistical analysis etc. as well as programming. There are just > too many possible data structures to expect logical consistency in their > handling throughout (if one can even define what that means in specific > instances!). I disagree with this claim: I think it is possible to crea

Re: [R] repeated searching of no-missing values

2008-12-10 Thread hadley wickham
On Wed, Dec 10, 2008 at 4:09 PM, Patrizio Frederic <[EMAIL PROTECTED]> wrote: > hi all, > I have a data frame such as: > > 1 blue 0.3 > 1 NA0.4 > 1 red NA > 2 blue NA > 2 green NA > 2 blue NA > 3 red 0.5 > 3 blue NA > 3 NA1.1 > > I wish to find the last non-missing value in every 3p

Re: [R] how to merge panel data stored by variable?

2008-12-10 Thread hadley wickham
On Wed, Dec 10, 2008 at 1:54 PM, Viktor Nagy <[EMAIL PROTECTED]> wrote: > 2008/12/10 Stefan Grosse <[EMAIL PROTECTED]> >> >> > I have two datasets stored in tab-separated format in the following way >> > file1: >> > country year1year2 >> > Germanyvar1 var1 >> > Hu

Re: [R] read.*: How to read from a URL?

2008-12-10 Thread hadley wickham
Hi Michael, In general, I think you should be able to do: gimage <- read.jpeg(url(gimageloc)) or alternatively use the EBImage from bioconductor which will read from a url automatically (it also opens a much wider range of file types) library(EBImage) img <- readImage(gimageloc, TrueColor) Had

Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread hadley wickham
On Wed, Dec 10, 2008 at 11:02 AM, baptiste auguie <[EMAIL PROTECTED]> wrote: > Dear list, > > I have a data.frame with x, y values and a 3-level factor "group", say. I > want to create a new column in this data.frame with the values of y scaled > to 1 by group. Perhaps the example below describes i

Re: [R] Polar coordinates - contour plots

2008-12-10 Thread hadley wickham
On Wed, Dec 10, 2008 at 4:33 AM, Todor Kondic <[EMAIL PROTECTED]> wrote: > Thanks Bert for the answer! I'll try to find an appropriate package. > In the end, i have "fiddling". > > But, can anyone tell me, were I to create an underlying implementation > of cooridnate transforms, perhaps controlled

Re: [R] == operand

2008-12-09 Thread hadley wickham
On Tue, Dec 9, 2008 at 5:36 PM, Renny Li <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to compare two values using "==" operand, please take a look of > the following example (I copied ALL what I did here without deleting any line) > >>bb<-1 >> cc<-50 >> cc==abs(bb+52) > [1] FALSE >> C<-53

Re: [R] Replacing tabs with appropriate number of spaces

2008-12-09 Thread hadley wickham
On Tue, Dec 9, 2008 at 10:39 AM, Dennis Fisher <[EMAIL PROTECTED]> wrote: > Colleagues, > > Platform: OS X (but issue applies to all platforms) > Version: 2.8.0 > > I have a mixture of text and data that I am outputting via R to a pdf > document (using a fixed-width font). The text contains tabs t

Re: [R] How to force aggregate to exclude NA ?

2008-12-07 Thread hadley wickham
On Sun, Dec 7, 2008 at 10:10 AM, Daren Tan <[EMAIL PROTECTED]> wrote: > > How to use the na.rm function outside aggregate ? I tried > > na.rm <- function(f) { > function(x, ...) f(x[!is.na(x)], ...) > } > > >>na.rm(sum(c(NA,1,2))) > > function(x, ...) f(x[!is.na(x)], ...) > > >> na.rm(sum, c(NA,1,

Re: [R] How to force aggregate to exclude NA ?

2008-12-07 Thread hadley wickham
>> aggregate(m[,-c(1:2)], by=list(m[,1]), mysum) <- this >> computes correctly. > Group.1 C D > 1 A 3 2 > 2 B 15 13 > 3 C 10 10 > 4 D 6 7 > 5 E 9 8 > >> aggregate(m[,-c(1:2)], by=list(m[,1]), mylength) <- this >> computes co

Re: [R] levels update

2008-12-05 Thread hadley wickham
On Fri, Dec 5, 2008 at 6:50 AM, Antje <[EMAIL PROTECTED]> wrote: > Hello, > > I hope this question is not too stupid. I would like to know how to update > levels after subsetting data from a data.frame. > > df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8), c(9,1,2,3,4)) > names(df) <-

Re: [R] complex(?) reshaping question

2008-12-05 Thread hadley wickham
> I'm trying to omit NA:s in this DF and produce a reduced DF. The > problem is that I cannot completely omit NA rows. > > I tried > > library(reshape) > g <- melt(DF, id=c("idvar1", "idvar2")) > g <- na.omit(g) You're missing an id variable: DF$idvar3 <- 1:2 g <- melt(DF, id=c("idvar1", "idvar2"

Re: [R] Bug in "transform"?

2008-12-03 Thread hadley wickham
On Wed, Dec 3, 2008 at 2:06 AM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Tue, 2 Dec 2008, hadley wickham wrote: > >>> The underlying issue is actually not in transform() but in data.frame(): >>> >>>> aq <- airquality[sample(1:153,6),] >&g

Re: [R] Speeding up casting a dataframe from long to wide format

2008-12-03 Thread hadley wickham
Hi Daren, Unfortunately, the current version of reshape isn't very efficient. I'm working on a new version which should be 10-20x times faster for the operation that you're performing, but this won't be ready for a while and in the meantime you might want to try an alternative approach, like the o

Re: [R] ggplot2 facet_wrap problem

2008-12-03 Thread hadley wickham
d an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of > data. > ~ John Tukey > > -Oorspronkelijk bericht- > Van: stephen sefick [mailto:[EMAIL PROTECTED] > Verzonden: woensdag 3 december 2008 1:09 > Aan: ONKELI

Re: [R] ggplot2 - suggestion for facet_wrap/grid

2008-12-03 Thread hadley wickham
Hi David, > facet_wrap and facet_grid function are both very usefull. But they are > perhaps a bit redundant. I disagree ;) Conceptually they are rather different: facet_wrap is essentially a 1d layout, while facet_grid is a 2d layout. This has implications for how you specify the faceting, how

Re: [R] Bug in "transform"?

2008-12-02 Thread hadley wickham
> The underlying issue is actually not in transform() but in data.frame(): > >> aq <- airquality[sample(1:153,6),] >> data.frame(aq, list(a=1,b=2)) > Error in data.frame(aq, list(a = 1, b = 2)) : > arguments imply differing number of rows: 6, 1 >> data.frame(aq, list(a=1)) >Ozone Solar.R Wind

Re: [R] Help with maps

2008-12-02 Thread hadley wickham
On Tue, Dec 2, 2008 at 6:21 PM, Avram Aelony <[EMAIL PROTECTED]> wrote: > A few questions about maps... > > (1) How can I find a listing of the internal data sets that map() from the > maps library contains? > For example, "usa", "county", "state", "nz" all work. Are there any others? help(packa

Re: [R] ggplot2 45deg axis labels

2008-12-02 Thread hadley wickham
Hi Stephen, Have a look at the "polishing your plot for publication" chapter of the ggplot2 book. Regards, Hadley On Tue, Dec 2, 2008 at 5:31 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > I would like to rotate the axis labels 45 deg. > > -- > Stephen Sefick > > Let's not spend our time and r

Re: [R] Question to regular expressions

2008-12-02 Thread hadley wickham
On Tue, Dec 2, 2008 at 9:48 AM, Antje <[EMAIL PROTECTED]> wrote: > Hi Gabor, > > it works! Thank you very much! But I still don't understand the difference > between [0-9] and [:digit:]... You might find this site helpful: http://regexp.resource.googlepages.com/analyzer.html Copy in your attempt

[R] Wiley Interdisciplinary Reviews

2008-12-02 Thread hadley wickham
They are obviously growing desperate - I have now been asked to write 5 articles! Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/po

Re: [R] How to refer to a list member by variable

2008-12-01 Thread hadley wickham
On Mon, Dec 1, 2008 at 12:53 PM, Reitsma, Rene - COB <[EMAIL PROTECTED]> wrote: > Dear All, > > I'm hoping one of you can help me with the following R problem. I'm > trying to refer to a member of a list by variable. However, this seems > not to work: > > foo=list(first=c(1:10),second=c(11:20)) > >

Re: [R] Non-interactive passing of quoted variables (ggplot, plyr, subset, transform, etc)

2008-12-01 Thread hadley wickham
On Mon, Dec 1, 2008 at 11:06 AM, Vitalie Spinu <[EMAIL PROTECTED]> wrote: > Hello Everyone, > May be a silly question. > > How to pass programmatically variables which are not known in advance and > are quoted? Variables are quoted implicitly in functions like "subset" and > "transform" and explic

Re: [R] controlling the number of times a script is repeated in a loop

2008-11-30 Thread hadley wickham
On Sun, Nov 30, 2008 at 12:21 PM, Salas, Andria Kay <[EMAIL PROTECTED]> wrote: > I am running a large for loop and at the end of each iteration a matrix is > produced. The program changes the columns in the matrix, and each time a > column is added the name of that column is "y". All original c

Re: [R] how to input a string without quote

2008-11-30 Thread hadley wickham
On Sun, Nov 30, 2008 at 11:38 AM, Carl Witthoft <[EMAIL PROTECTED]> wrote: > "From: Yihui Xie > Date: Sun, 30 Nov 2008 15:32:35 +0800 > > Wow, you are so lazy... But sometimes R is just designed for lazy guys... " > > > Yeah, well, laziness is the mother of creativity :-) . > But seriously: I kno

Re: [R] R window lines limit

2008-11-28 Thread hadley wickham
On Fri, Nov 28, 2008 at 9:00 AM, Rthoughts <[EMAIL PROTECTED]> wrote: > > Hi, > > Is the number of lines that can be displayed in R GUI limited? > > When I do a Fourier Tranform of 4000 data points, I can only see the last > 300 or so of it. I need to see all of it. How is this possible? Perhaps y

Re: [R] as.numeric in data.frame, but only where it is possible

2008-11-27 Thread hadley wickham
On Thu, Nov 27, 2008 at 12:53 AM, Kinoko <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to convert my "character" sequences in my matrix/ > data.frame into "numeric" where it is possible. > I would also like to retain my alphabetic character strings in their > original forms. > "5.1" > 5.1

Re: [R] Reshape with var as fun.aggregate

2008-11-26 Thread hadley wickham
Hi Jason, The reason you are getting this error is that the latest version of reshape uses fun.aggregate(numeric(0)) to figure out what missing values should be filled in with. Unfortunately there was a brief period in R versions when var(numeric(0)) returned an error rather than a missing value.

Re: [R] Very slow: using double apply and cor.test to compute correlation p.values for 2 matrices

2008-11-26 Thread hadley wickham
On Wed, Nov 26, 2008 at 8:14 AM, jim holtman <[EMAIL PROTECTED]> wrote: > Your time is being taken up in cor.test because you are calling it > 100,000 times. So grin and bear it with the amount of work you are > asking it to do. > > Here I am only calling it 100 time: > >> m1 <- matrix(rnorm(1

Re: [R] Heat Maps

2008-11-25 Thread hadley wickham
On Tue, Nov 25, 2008 at 9:18 AM, Jacques Wagnor <[EMAIL PROTECTED]> wrote: > Dear List, > > Does there exist a function that produces a heat map like this one > (image 3 of 4): > > http://www.tdameritrade.com/tradingtools/options360.html?a=HDY&referrer=http%3A%2F%2Fquery.nytimes.com%2Fsearch%2Fsite

Re: [R] Count days of current year

2008-11-25 Thread hadley wickham
Why not write it yourself? days_in_year <- function(year) { 365 + (year %% 4 == 0) - (year %% 100 == 0) + (year %% 400 == 0) } This should work for any year in the Gregorian calendar. Hadley On Mon, Nov 24, 2008 at 1:25 PM, Felipe Carrillo <[EMAIL PROTECTED]> wrote: > Hi: > Is there a functio

Re: [R] ggplot2: positioning legend on top of plot

2008-11-24 Thread hadley wickham
Hi Paul, That's a bug - I'll look into it. Regards, Hadley On Mon, Nov 24, 2008 at 10:46 AM, Paul Emberson <[EMAIL PROTECTED]> wrote: > Hi, > > With ggplot2 v0.8, how do I position a legend on top of the plot. Things > like > > p + opts(legend.position="top") > > work ok. But > > p + opts(lege

Re: [R] ggplot2 - facet_grid and facet_wrap

2008-11-24 Thread hadley wickham
ars, geom = "line") # works > > qplot(mpg, wt, data=mtcars) + facet_grid(cyl ~ vs) # works > > qplot(mpg, wt, data=mtcars, geom = "line") + facet_grid(cyl ~ vs) > Erreur dans grobs[[i, j]] <- layer$make_grob(layerd[[i, j]], details, coord) > : > types (

Re: [R] ggplot2 - facet_grid and facet_wrap

2008-11-23 Thread hadley wickham
Hi David, That looks like a bug! I'll look into it. Regards, Hadley On Sat, Nov 22, 2008 at 1:07 PM, David Hajage <[EMAIL PROTECTED]> wrote: > Hello R users (and Hadley) > > I have another question about ggplot2 :-) > > (version 0.8) > > `dat` <- > structure(list(D = c("a", "b", "c", "d"), G =

Re: [R] What's the BEST way in R to adapt this vector?

2008-11-22 Thread hadley wickham
On Sat, Nov 22, 2008 at 12:00 PM, zerfetzen <[EMAIL PROTECTED]> wrote: > > Goal: > Suppose you have a vector that is a discrete variable with values ranging > from 1 to 3, and length of 10. We'll use this as the example: > > y <- c(1,2,3,1,2,3,1,2,3,1) > > ...and suppose you want your new vector (

[R] [R-pkgs] ggplot2 - version 0.8

2008-11-21 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] Identify command in R]

2008-11-20 Thread hadley wickham
Reading in between the lines a little, maybe you want lm(..., na.action = na.exclude) That should return missing values for the influence statistics when the predictor or responses is missing in the input. Hadley On Thu, Nov 20, 2008 at 4:19 PM, David Kaplan <[EMAIL PROTECTED]> wrote: > Let me

Re: [R] Problem with ggplot2

2008-11-20 Thread hadley wickham
Hi David, I inadvertently introduced a bug in ggplot in the last release. I uploaded a fix to CRAN this morning and it should be available in the near future. Sorry for the inconvenience. Regards, Hadley On Thu, Nov 20, 2008 at 2:49 PM, David Hajage <[EMAIL PROTECTED]> wrote: > Hello R users,

Re: [R] Calculating SD according to groups of rows

2008-11-20 Thread hadley wickham
On Thu, Nov 20, 2008 at 10:04 AM, Dieter Menne <[EMAIL PROTECTED]> wrote: > hadley wickham gmail.com> writes: > >> > library(plyr) >> > dat = data.frame(SUBJECT_ID=sample(letters[1:5],100,TRUE),HR=rnorm(100)) >> > daply(dat,.(SUBJECT_ID),sd) >&g

Re: [R] Calculating SD according to groups of rows

2008-11-20 Thread hadley wickham
like that; I personally got used to it, but I admit > it is one of the thinks that are unusually difficult in R. > > dat = data.frame(SUBJECT_ID=sample(letters[1:5],100,TRUE),HR=rnorm(100)) > sd.list = with(dat, tapply(HR, SUBJECT_ID, sd)) > data.frame(SUBJECT_ID=rownames(sd.list),sd

Re: [R] ggplot2; dot plot, jitter, and error bars

2008-11-19 Thread hadley wickham
On Wed, Nov 19, 2008 at 5:34 PM, Juliet Hannah <[EMAIL PROTECTED]> wrote: > With this data > > x <- c(0,0,1,1,2,2) > y <- c(5,6,4,3,2,6) > lwr <- y-1 > upr <- y+1 > xlab <- c("Low","Low","Med","Med","High","High") > mydata <- data.frame(x,xlab,y,lwr,upr) > > I would like to make a dot plot and use

Re: [R] Exclude holidays in a subset of dates?

2008-11-19 Thread hadley wickham
On Wed, Nov 19, 2008 at 12:54 PM, Brigid Mooney <[EMAIL PROTECTED]> wrote: > Hi All, > > I am iterating through dated materials, with variable start and end dates, > and would like to skip procedures everytime I encounter a weekend or > holiday. To do this, I thought the easiest way would be to cr

Re: [R] ggplot2: can one have separate ylim for each facet?

2008-11-17 Thread hadley wickham
On Mon, Nov 17, 2008 at 3:49 PM, Etches Jacob <[EMAIL PROTECTED]> wrote: > In lattice > > #toy data > library(ggplot2) > library(lattice) > x <- rnorm(100) > y <- rnorm(100) > k <- sample(c("Weak","Strong"),100,replace=T) > j <- sample(c("Tall","Short"),100,replace=T) > w <- data.frame(x,y,j,k) > >

Re: [R] An array of an array of boxplots in lattice

2008-11-17 Thread hadley wickham
On Mon, Nov 17, 2008 at 3:42 PM, steve <[EMAIL PROTECTED]> wrote: > Thank you. Here's my version, using melt instead of do.call(make.groups... > > library(reshape) > fgl2 = melt(fgl[,-10]) > fgl2$type = fgl$type > bwplot(value ~ type | variable, data = fgl2) Or even more succintly: fgl2 <- melt(f

Re: [R] The use of F for False and T for True

2008-11-17 Thread hadley wickham
On Sun, Nov 16, 2008 at 7:41 PM, Simon Blomberg <[EMAIL PROTECTED]> wrote: > It is better programming practice to use FALSE for false and TRUE for > true, and not F and T. This is because it is quite legal to do this: > > T <- FALSE > F <- TRUE It may be better programming practice, but is it bett

Re: [R] ggplot2: using more than 6 symbols

2008-11-17 Thread hadley wickham
Hi Dave, On Mon, Nov 17, 2008 at 6:35 AM, Dave Murray-Rust <[EMAIL PROTECTED]> wrote: > I'm trying to plot multiple lines using different colours/symbols to > distinguish them. If I try to plot more than 6 lines, I get an error: > >> ggplot( dat, aes(x=time,y=value,group=variable,shape=variable) )

Re: [R] Manipulating lists

2008-11-16 Thread hadley wickham
On Sun, Nov 16, 2008 at 9:56 PM, Christian Arnold <[EMAIL PROTECTED]> wrote: > Hello R-Community, > > I am pretty new to R and I am fascinated what R can do! I am doing > phylogenetic analysis in R, and my current project includes two problems > that I am unable to solve, unfortunately. I am hoping

Re: [R] how to calculate another vector based on the data from a combination of two factors

2008-11-16 Thread hadley wickham
On Sun, Nov 16, 2008 at 8:12 PM, jeffc <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a data set similar to the following > > State Gender Quantity > TX Male1 > NY Female 2 > TX Male3 > NY Female 4 > > > I need to calculate cumulative sum of the quantity by State and

Re: [R] Superimposing y-variables in Lattice formulas

2008-11-16 Thread hadley wickham
Hi Stavros, > I think we're talking past each other on the question of the semantics > of formula operators, and it's probably not productive to continue. I > would guess that the underlying issue is that we come from different > communities, and so have different background assumptions. Perhaps

Re: [R] ggplot2 - two or more axis

2008-11-14 Thread hadley wickham
Hi David, > I'm trying to learn how to make a plot with the amazing package ggplot2. > > I was wondering if it was possible to draw 2 (or more) x (or y) axis in the > same graph. For example : > - I want to show two informations at each x coordinate : a survival curve, > I want to show the time (

Re: [R] TimeZone Help - Finding TimeZone codes

2008-11-13 Thread hadley wickham
On Thu, Nov 13, 2008 at 9:10 PM, J Dougherty <[EMAIL PROTECTED]> wrote: > On Monday 10 November 2008 01:23:30 pm Prof Brian Ripley wrote: >> See ?Sys.timezone, which help.search("timezone") points you to. >> >> On Mon, 10 Nov 2008, stephen sefick wrote: >> > I have looked at >> > ?as.POSIXct >> >>

Re: [R] Citing R in journal articles (or the failure to)

2008-11-12 Thread hadley wickham
> Along similar lines, someone recently posted a script to generate > a .bib file for all packages installed. It would be useful if someone > were to implement that script for CRAN and make the resulting > R-packages.bib file available on the CRAN site. It would also be useful if citation() added

Re: [R] any alternatives for complex for-loops?

2008-11-11 Thread hadley wickham
On Tue, Nov 11, 2008 at 8:30 PM, Kinoko <[EMAIL PROTECTED]> wrote: > Dear list, > > Is there a way to do something like the following pseudo-code - > without for loop? There isn't a for loop in your code! Hadley > > complexFn <- function(a,b){ > ... > return(c) > } > > x[i] = complexFn(x[i-1],

Re: [R] R design (was "Variable passed to function not used in function in select)

2008-11-11 Thread hadley wickham
> That's why (I think) it should be an *** optional argument > with default set to FALSE *** ... it's clear from the past traffic > on the list (I won't take the time to dig up the thread > references right now) that there is at the very least > a significant minority of users who expect the oppos

Re: [R] Reading tables using a truncated name

2008-11-11 Thread hadley wickham
Which can be simplified to: paths <- dir(path = filePath, pattern = "^test_", full = T) lapply(paths, read.csv) Hadley On Tue, Nov 11, 2008 at 2:01 PM, <[EMAIL PROTECTED]> wrote: > Hi all, > > Thanks everyone for your advice. They have been helpful. > > Just for the record, I am using ... > > l

Re: [R] Reading tables using a truncated name

2008-11-11 Thread hadley wickham
?dir Hadley On Tue, Nov 11, 2008 at 11:06 AM, <[EMAIL PROTECTED]> wrote: > Dear all, > > I am trying to read a bunch of csv files using read.table() that are named > "test_xx.csv" where "xx" has no particular pattern. Is there a way > of reading all the files by specifying a truncated fi

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread hadley wickham
> I think your analysis is correct, that the goals of casual use and > programming are inconsistent. But in general I think there's always going > to be support for providing alternative ways that are programmer-safe. > > For instance, library( foo, character.only=TRUE) says that foo is a > charac

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread hadley wickham
> And without wanting to be rude or anything, your opinion carries very > little weight in a project like R. You've arrived on the list and been > very critical of the work of others. Now there is nothing wrong with > being critical if it is constructive, and additionally with something > like R yo

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread hadley wickham
On Mon, Nov 10, 2008 at 1:04 PM, Wacek Kusnierczyk <[EMAIL PROTECTED]> wrote: > pardon me, but does this address in any way the legitimate complaint of > the rightfully confused user? > > consider the following: > > d = data.frame(a=1, b=2) > a = c("a", "b") > z = a > # that is, both a and z are c(

Re: [R] how to stop without error message?

2008-11-10 Thread hadley wickham
> > I should have been clearer, sorry-- I'm trying to exit from an "inner" > function which might be several levels deep, returning straight to the R > prompt. To be specific, I'm trying to clean up the "No Error in..." message > in my 'debug' package-- the "No " prefix being my original workaro

Re: [R] how to stop without error message?

2008-11-10 Thread hadley wickham
On Mon, Nov 10, 2008 at 4:42 PM, <[EMAIL PROTECTED]> wrote: > Dear list > > Can anyone suggest a simple way to abort execution like stop(...) does, but > without issuing an "Error: ..." message? > > I don't want to set 'options( show.error.messages=TRUE)' because I want > normal behaviour to res

Re: [R] Election Maps

2008-11-07 Thread hadley wickham
On Fri, Nov 7, 2008 at 7:53 AM, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 11/7/2008 8:31 AM, roger koenker wrote: >> >> Those of you with an interest in the US election and/or >> statistical graphics may find the maps at: >> >>http://www-personal.umich.edu/~mejn/election/2008/ >> >> in

Re: [R] Including graphics files in MS office / open office

2008-11-06 Thread hadley wickham
see ?xfig. > > Best, > > Philippe > ..<°}))>< > ) ) ) ) ) > ( ( ( ( (Prof. Philippe Grosjean > ) ) ) ) ) > ( ( ( ( (Numerical Ecology of Aquatic Systems > ) ) ) ) ) Mons-Hainaut University, Belgium > ( ( ( ( ( > ...

Re: [R] Including graphics files in MS office / open office

2008-11-06 Thread hadley wickham
On Thu, Nov 6, 2008 at 10:05 AM, Max Kuhn <[EMAIL PROTECTED]> wrote: >> * svg: R output devices still experimental > > I've been using the svg device in the Cairo package for a while now. > I've never had any issues with it and wouldn't characterize it as > experimental (of course, others may have

[R] Including graphics files in MS office / open office

2008-11-06 Thread hadley wickham
Hi all, I'm trying to write up some recommendations for what graphics formats are most useful for inclusion into ms office and openoffice. There have been a few discussions on the list in the past, but I haven't seen a summary. These are the options I've seen so far, along with there costs and b

Re: [R] how can I save the estimates of a regression model in a file?

2008-11-05 Thread hadley wickham
On Wed, Nov 5, 2008 at 11:12 AM, pilar schneider <[EMAIL PROTECTED]> wrote: > Dear all > I need some help with R. > How can I save the estimates of a regression model in a file? > > here is what I did: > > 1) this is my regression model: > fit1 <- lm(logmilk ~ logdays + days, data=data2) > > 2) how

Re: [R] TukeyHSD and 0.0000000

2008-11-05 Thread hadley wickham
On Wed, Nov 5, 2008 at 5:42 AM, Fredrik Karlsson <[EMAIL PROTECTED]> wrote: > Dear list, > > Sorry to ask you this, but I just ran a TukeyHSD on an model with a > two thee level factors as independent variables and a numeric score > dependent variable. > The aov gives a significant interaction effe

Re: [R] ggplot & annotating charts

2008-11-04 Thread hadley wickham
Hi Simeon, Could you publish vixarchive.csv too please? Do you have a start on the version in ggplot2? It would be useful to see that code too. Hadley On Tue, Nov 4, 2008 at 8:49 AM, simeon duckworth <[EMAIL PROTECTED]> wrote: > Dear "R-listers" > > I've been trying to figure out how to annotat

Re: [R] reshape bug?

2008-11-04 Thread hadley wickham
v 4, 2008 at 9:25 AM, hadley wickham <[EMAIL PROTECTED]> wrote: >> Hi Stephen, >> >> Thanks for the bug report (and apologies for the delay getting back to >> you). I'm working on a fix today and will hopefully release a new >> version in the very nea

Re: [R] ggplot2 scatterplot matrix

2008-11-04 Thread hadley wickham
> plotmatrix(d[,3:6]) > > I would like to either have a colour or more preferably a shape to > correspond to Site > this is what I have tried (along with many other combinations) > plotmatrix(nmds.bug[,3:6])+scale_shape(nmds.bug, shape=Site, pch=1:12) There's not really any easy way to do this in

Re: [R] reshape bug?

2008-11-04 Thread hadley wickham
Hi Stephen, Thanks for the bug report (and apologies for the delay getting back to you). I'm working on a fix today and will hopefully release a new version in the very near future. Hadley On Fri, Oct 31, 2008 at 12:51 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > Hadley et al., > I was using

Re: [R] a "date" x-axis in a xyplot

2008-11-04 Thread hadley wickham
Is your variable actually a date? R doesn't recognise dates automatically - you need to create them with as.Date or similar. Hadley On Tue, Nov 4, 2008 at 3:22 AM, <[EMAIL PROTECTED]> wrote: > > Dear all, > > In the x-axis of a xyplot I define dates ,for example 01-10-2007 instead of > numbers

Re: [R] How do you apply a function to each variable in a data frame?

2008-11-03 Thread hadley wickham
On Mon, Nov 3, 2008 at 9:02 AM, Jorge Ivan Velez <[EMAIL PROTECTED]> wrote: > Dear zerftezen, > Try this: > > # Data > set.seed(123) > X=as.data.frame(matrix(rnorm(100),ncol=10)) > > # Percentiles 10 and 90 using apply > t(apply(X,2,quantile,probs=c(0.1,0.9))) > > # The same using sapply > t(sapply

Re: [R] How to plot with different colours

2008-11-02 Thread hadley wickham
Hi Carlos, I'd strongly urge to reconsider your colour choices - 7-10% of males are red-green colour blind and it will be difficult for them to tell the difference between the high and low values. Hadley On Sat, Nov 1, 2008 at 11:58 PM, Carlos Morales <[EMAIL PROTECTED]> wrote: > Hello everyone,

Re: [R] Help needed with Waterfall plot

2008-11-01 Thread hadley wickham
On Fri, Oct 31, 2008 at 11:25 AM, Philip Twumasi-Ankrah <[EMAIL PROTECTED]> wrote: > Hi friends, > I need suggestions/directions on how to producing a waterfall plot for > present extend of change in tumour size for a set of respondents in a study. > Example of use of waterfall plot is in the fo

Re: [R] Splitting device for ggplots?

2008-11-01 Thread hadley wickham
On Sat, Nov 1, 2008 at 5:13 AM, baptiste auguie <[EMAIL PROTECTED]> wrote: > Hi, > > I believe you can apply the same procedure as described in Paul Murrell's "R > graphics" book for arranging lattice plots. Yup, and see also http://had.co.nz/ggplot2/book/grid.pdf Hadley -- http://had.co.nz/

Re: [R] combine symbol beta and text in ggplot2 and adjust size

2008-10-30 Thread hadley wickham
> For this example: > > library(ggplot2) > p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point() > p <- p + scale_x_continuous(expression(beta)) > p > > How can I include text with the expression. For example, "level of > \beta". Also, how can I increase Have a look at ?plotmath - you want someth

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