Re: [R] histogram plots with many different samples

2009-03-25 Thread hadley wickham
Or use frequency polygons, if you want to stay with the interpretability of a histogram. Hadley On Wed, Mar 25, 2009 at 12:07 PM, Greg Snow wrote: > Personally I find those types of plots difficult to interpret.  Much easier > to create, view, and interpret is to simply plot the lines from densi

Re: [R] Following progress in a lapply() function

2009-03-22 Thread hadley wickham
On Sun, Mar 22, 2009 at 5:06 PM, Blanchette, Marco wrote: > Dear all, > > I am processing a very long and complicated list using lapply through a > custom function and I would like to generate some sort of progress report. > For instance, print a dot on the screen every time 1000 item have been

Re: [R] Fisher test accuracy in doubt

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

Re: [R] Retrieving Vertices Coordinates from SpatialPolygons

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

Re: [R] ggplot2: specifying legend titles

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

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

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

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

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

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

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

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

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

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

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

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

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

Re: [R] popular R packages

2009-03-09 Thread hadley wickham
> There was a discussion on this a while back in which Bill Venables > said: "To me a much more urgent initiative [than rating responders on > R listserves] is some kind of user online review system for packages, > even something as simple as that used by Amazon.com has for customer > review of boo

Re: [R] popular R packages

2009-03-08 Thread hadley wickham
>> I question 1) the usefulness of the effort necessary to get the data ; >> and 2) the very concept of data mining, which seems to be the rationale >> for this proposed effort. >> >> Furthermore (but this is seriously off-topic), I seriously despise the >> very idea of "popularity" in scientific d

Re: [R] popular R packages

2009-03-08 Thread hadley wickham
> More seriously : I don't think relative numbers of package downloads can > be interpreted in any reasonable way, because reasons for package > download have a very wide range from curiosity ("what's this ?"), fun > (think "fortunes"...), to vital need tthink lme4 if/when a consensus on > denomina

Re: [R] Using vectors of names in calls for functions

2009-03-05 Thread hadley wickham
Hi Pascal, You need the aes_string function: V1_P2_plot<-function(df, x, y, z) { ggplot(df, aes_string(x = x, y= y, fill = z)) + geom_tile() } j<-c("k", "l") i<-"m" m<-rnorm(25) vsim<-cbind(expand.grid(k=1:5, l=1:5*10), m) V1_P2_plot(df=vsim, x=j[1], y=j[2], z=i) Hadley On Thu, Mar 5, 2

Re: [R] Bug in by() with dates as levels?

2009-03-04 Thread hadley wickham
On Wed, Mar 4, 2009 at 5:22 PM, oren cheyette wrote: > Trying to use dates in their R-native form (e.g., POSIXct) rather than > turning them into character strings, I've encountered the following problem. > I create a data frame where one column is dates. Then I use "by()" to do a > calculation on

Re: [R] Table Transformation

2009-03-04 Thread hadley wickham
On Wed, Mar 4, 2009 at 11:58 AM, Christian Pilger wrote: > > Dear R-experts, > > recently, I started to discover the world of R. I came across a problem, > that I was unable to solve by myself (including searches in R-help, etc.) > > I have a flat table similar to > > key1    key2    value1 > > ab

Re: [R] Selecting one row or multiple rows per ID

2009-03-04 Thread hadley wickham
On Wed, Mar 4, 2009 at 12:09 AM, Vedula, Satyanarayana wrote: > Hi, > > Could someone help with coding this in R? > > I need to select one row per patient i in clinic j. The data is organized > similar to that shown below. > > Two columns - patient i in column j identify each unique patient. Ther

Re: [R] Writing R package and do.call

2009-03-02 Thread hadley wickham
On Mon, Mar 2, 2009 at 7:46 PM, Rob Foxall wrote: > Dear R-Help, > > I have written a function, which in simplified format can be represented as: > > temp.fn <- function(my.mean,my.sd){ >   Parameters <- list(mean = my.mean, sd = my.sd) >   curve(do.call(dnorm,c(list(x), Parameters)), from = my.me

Re: [R] ways to put multiple graphs on single page (using ggplot2)

2009-03-02 Thread hadley wickham
Hi Juliet, Have a look at the last section in http://had.co.nz/ggplot2/book/polishing.pdf Hadley On Mon, Mar 2, 2009 at 12:35 PM, Juliet Hannah wrote: > Hi, Here are three plots: > > library(ggplot2) > data(diamonds) > randind <- sample(nrow(diamonds),1000,replace=FALSE) > dsmall <- diamonds[ra

Re: [R] bottom legends in ggplot2 ?

2009-02-27 Thread hadley wickham
Yes, this is a known bug which will (hopefully) be addressed in the next release. Hadley On Fri, Feb 27, 2009 at 4:15 AM, ONKELINX, Thierry wrote: > I would think that the lines below should work but they give an error. > Hadley, can you clarify this? > > Cheers, > > Thierry > >> library(ggplot2)

Re: [R] Download daily weather data

2009-02-26 Thread hadley wickham
See also http://umbrellatoday.com/ Hadley On Thu, Feb 26, 2009 at 2:47 PM, Thomas Levine wrote: > I'm writing a program that will tell me whether I should wear a coat, > so I'd like to be able to download daily weather forecasts and daily > reports of recent past weather conditions. > > The NOAA

Re: [R] reshape from wide to long

2009-02-25 Thread hadley wickham
On Wed, Feb 25, 2009 at 10:01 PM, Juliet Hannah wrote: > Out of curiosity, what would be a good way to do this without using > the reshape package? Thanks! Well the core of the melt code is this: ids <- data[, var$id, drop = FALSE] df <- do.call("rbind", lapply(var$measure, function(x) {

Re: [R] Have a function like the "_n_" in R ? (Automatic count function )

2009-02-25 Thread hadley wickham
On Wed, Feb 25, 2009 at 8:41 AM, Wacek Kusnierczyk wrote: > hadley wickham wrote: >> And for completeness here's a function that returns the next integer >> on each call. >> >> n <- (function(){ >>   i <- 0 >>   function() { >>     i <&

[R] [R-pkgs] ggplot2 0.8.2

2009-02-25 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] Have a function like the "_n_" in R ? (Automatic count function )

2009-02-25 Thread hadley wickham
And for completeness here's a function that returns the next integer on each call. n <- (function(){ i <- 0 function() { i <<- i + 1 i } })() > n() [1] 1 > n() [1] 2 > n() [1] 3 > n() [1] 4 > n() [1] 5 > n() [1] 6 ;) Hadley On Wed, Feb 25, 2009 at 8:27 AM, David Winsemius wrote

Re: [R] Grouped bwplots?

2009-02-21 Thread hadley wickham
On Fri, Feb 20, 2009 at 3:57 PM, Fredrik Karlsson wrote: > Dear list, > > I am sorry for asking you this, but I am trying to do again what I > thought I have done before, although this time it does not work. > > So, given the data set: > >> testdf <- data.frame(grfak=sample(c("One","Two"),size=100

Re: [R] error bars

2009-02-19 Thread hadley wickham
On Thu, Feb 19, 2009 at 1:19 AM, jdeisenberg wrote: > > > Nicole Hackman wrote: >> >> Hello, I have a very simple data set i imported from excel including 96 >> averages in a column along with 96 standard errors associated with those >> averages (calculated in excel). I plotted the 95 averages us

Re: [R] ggplot2 Y axis labels

2009-02-18 Thread hadley wickham
On Wed, Feb 18, 2009 at 4:21 PM, Felipe Carrillo wrote: > Hi all: > Using the example below, is there a way to add Y axis titles to each graphic > instead of sharing the same title? Not at the moment, no. It's on my to do list. Hadley > > library(ggplot2) > > RT = matrix(c(814, 500, 424, 394,

Re: [R] joining "one-to-many"

2009-02-17 Thread hadley wickham
On Tue, Feb 17, 2009 at 8:33 AM, Monica Pisica wrote: > > Hello list, > > I am wondering if a joining "one-to-many" can be done a little bit easier. I > tried merge function but I was not able to do it, so I end up using for and > if. > > Suppose you have a table with locations, each location re

Re: [R] scatterplot and correlation for weird data format

2009-02-16 Thread hadley wickham
On Mon, Feb 16, 2009 at 10:21 AM, William Simpson wrote: > I have data in a format like this: > > namessexsex viewnum rating rt > ahl4f m f 56 -1082246 > ahl4f m f 74 85 1444 > ahl4f m f 52

[R] Houston area R meetup

2009-02-14 Thread hadley wickham
Hi all, Could you please email me off-list if you'd be interested (and able) in attending a regular R meetup in Houston. Very tentatively it would be held the last Monday or Wednesday of the month, 5-6:30pm at Rice University. It could be as formal as informal as you like, but I'm imagining a so

Re: [R] help change auto.key colors in xyplot

2009-02-13 Thread hadley wickham
On Fri, Feb 13, 2009 at 1:22 PM, Dieter Menne wrote: > Dimitri Liakhovitski gmail.com> writes: > >> the code below works just fine to produce a dotplot. However, I am not >> successful changing the color of the lines in the legend (auto.key). >> If I add col=..., it only changes the color of the

Re: [R] System.time

2009-02-12 Thread hadley wickham
On Thu, Feb 12, 2009 at 8:42 AM, Stavros Macrakis wrote: > On Thu, Feb 12, 2009 at 4:28 AM, Gavin Simpson > wrote: >> When I'm testing the speed of things like this (that are in and of themselves >> very quick) for situations where it may matter, I wrap the function call in >> a call >> to repl

Re: [R] Can't install rggobi package

2009-02-11 Thread hadley wickham
Have you installed ggobi successfully? Exactly what problem are you having with the installation? Regards, Hadley On Wed, Feb 11, 2009 at 3:21 PM, wrote: > I am unable to install the rggobi package. I do not have trouble > installing other packages. Any advice or suggestions? > > >>session

[R] [ANN] ggplot2 + rggobi course. July 30-31, Washington DC

2009-02-10 Thread hadley wickham
All proceeds go to the GGobi Foundation to support graphics research. Find out more, and book your tickets online at http://lookingatdata.com Regards, Hadley Wickham Dianne Cook -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.et

Re: [R] updating contents of a package

2009-02-08 Thread hadley wickham
On Sun, Feb 8, 2009 at 4:26 AM, Dieter Menne wrote: > Markus Loecher gmail.com> writes: > >> I read through the "Writing R Extensions" document and am able to now create >> my own packages/libraries which so far are just well documented collections >> of my own R functions. I use package.skeleton

Re: [R] how to make this qq plot in lattice and/or ggplot2

2009-02-08 Thread hadley wickham
On Sat, Feb 7, 2009 at 9:25 PM, Juliet Hannah wrote: > Hi Group, > > Here is some data. > > p <- runif(1000) # sample data > groups <- rep(c(1,2),each=500) #conditioning variable > mydata <- cbind(p,groups) > n <- length(p) > u <- (1:n)/(n + 1) # uniform distribution reference for qqplot > logp <-

Re: [R] A way to "lock down" the order of bars for ggplot "dodged"histogram

2009-02-06 Thread hadley wickham
Yes, I think it is. I'll add it to my to do list. Hadley On Fri, Feb 6, 2009 at 3:30 AM, ONKELINX, Thierry wrote: > Hmm, I had not tested my solution. But that used to work. But I'm getting > the same result as you do. So maybe this is a bug in ggplot2. Is it, Hadley? > > Thierry > > ---

Re: [R] Problems in Recommending R

2009-02-05 Thread hadley wickham
On Thu, Feb 5, 2009 at 8:56 PM, Patrick Connolly wrote: > On Sun, 01-Feb-2009 at 11:34PM -0500, Stavros Macrakis wrote: > > |> A first step that would make the current Web page look much better > |> would be to anti-alias the demonstration graphic. The current graphic > |> makes R graphics seem (

Re: [R] Problems in Recommending R

2009-02-05 Thread hadley wickham
On Thu, Feb 5, 2009 at 8:32 AM, hadley wickham wrote: >> > I don't think you should completely rule out javascript. It's >> > possible to use it in ways that add to the utility of a page, while >> > not detracting from it if not available. >> &

Re: [R] Problems in Recommending R

2009-02-05 Thread hadley wickham
> > I don't think you should completely rule out javascript. It's > > possible to use it in ways that add to the utility of a page, while > > not detracting from it if not available. > > OK, what particularly do you have in mind? Here's a few of examples off the top of my head. These are thin

Re: [R] In qplot, is it possible to switch the location of axis_h and strip_h?

2009-02-04 Thread hadley wickham
On Wed, Feb 4, 2009 at 1:21 PM, Jason Rupert wrote: > That is qplot, is it possible to switch the location of axis_h and strip_h? > > I produced a plot where I would like to have the strip_h on the bottom and > the axis_h on the top of the facet plot. Is that possible? Not yet, but it's on my

Re: [R] Problems in Recommending R

2009-02-04 Thread hadley wickham
> > It might be good to put some mild restriction on the design: > > > * should be valid (x)html and css > > Of course (although the current page also does not validate without > errors ;-) > > > * use the YUI css grid framework for layout > > Never heard about that one, but looks sensible. >

Re: [R] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread hadley wickham
On Wed, Feb 4, 2009 at 10:55 AM, Ian Fiske wrote: > Thanks for the suggestion, Hadley. I tried: > > stat_smooth(fill=alpha("grey",1)) > > and got the same problem. The shaded band shows up in the graphics > windows, but the only file format the keeps the confidence band is > PDF. > > Am I doing

Re: [R] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread hadley wickham
On Wed, Feb 4, 2009 at 9:12 AM, Ian Fiske wrote: > > Hi all, > > I am using ggplot2 and continuing to find it very useful and pretty. > However, I am trying to create some graphics for publication that would be > included in an MS Word document (not my choice!) in Windows Vista. > > The problem is

Re: [R] Problems in Recommending R

2009-02-04 Thread hadley wickham
> > One of my colleagues is a interdisciplinary PhD in Design and > > Psychology and he has an "in" with a design school where we might be > > able to get students to take on the redesign of the website. > > Thanks a lot, sounds exactly like what we need. If they don't succeed > we can always by

Re: [R] overlapping bars on "dodge" ggplot histogram - can it be fixed?

2009-02-04 Thread hadley wickham
On Wed, Feb 4, 2009 at 9:26 AM, Jason Rupert wrote: > Hadley, > > Thank you again for your suggestion. > > I am going with the second solution. It appears to have a consistent bar > width and helps to illustrate when data is not present within a certain > bin. > > One other silly question - how i

Re: [R] Time series plots with ggplot

2009-02-03 Thread hadley wickham
On Tue, Feb 3, 2009 at 12:58 PM, Harsh wrote: > Hi, > I am newbie user of ggplot and would like some assistance in > implementing time series plots. > > I'd like to know how the tsdiag plot can be made in ggplot? It's not particularly easy because the code for tsdiag interweaves computing statist

Re: [R] lapply and aggregate function

2009-02-03 Thread hadley wickham
> # Second > set.seed(321) > myD <- data.frame( Light = sample(LETTERS[1:2], 10, replace=T), >value=rnorm(20) ) > > w1 <- tapply(myD$value, myD$Light, mean) > w1 > # > w1 > # A B > # 0.4753412 -0.2108387 > > myfun <- function(x) (myD$value > w1[x] & myD$value <

Re: [R] Problems in Recommending R

2009-02-03 Thread hadley wickham
> The most useful thing (and quite rightly so) on the front page is the link > the the FAQ which should be the starting point for anyone looking at any new > software, and answers/explains everything thats pertinent! (At least thats > what I read first when I start using new software and have ques

Re: [R] Problems in Recommending R

2009-02-03 Thread hadley wickham
On Tue, Feb 3, 2009 at 9:03 AM, Peter Dalgaard wrote: > hadley wickham wrote: >>>> >>>> 1. avoid clicking on the "R version 2.8.1" link - that takes you to a >>>> directory listing of strangely named files > > Yes, this is of course mu

Re: [R] Problems in Recommending R

2009-02-03 Thread hadley wickham
>> 1. avoid clicking on the "R version 2.8.1" link - that takes you to a >> directory listing of strangely named files >> >> 2. recognise that you need to click on an CRAN (what is a cran?) >> >> 3. successfully select a mirror that is up-to-date (with no >> information about which mirrors are u

Re: [R] Problems in Recommending R

2009-02-03 Thread hadley wickham
> Again I'd disagree, perhaps the most widely used suite of software has a > very simple and clean web-site with few bells and whistles, ditto for one of > the most popular text-editors. I am of course referring to the suite of GNU > utilities (http://www.gnu.org/) that make a working GNU/Linux di

Re: [R] overlapping bars on "dodge" ggplot histogram - can it be fixed?

2009-02-02 Thread hadley wickham
n)) + > geom_bar(position=position_dodge(width =(15)), binwidth=20) > > The result shows the bars overlapping. > > Is there any way to fix it by reducing the bar sizes? > > Thanks again. > > --- On Mon, 2/2/09, hadley wickham wrote: > > From: hadley wickham > Subjec

Re: [R] Broke ggplot...

2009-02-02 Thread hadley wickham
On Mon, Feb 2, 2009 at 5:41 PM, Jason Rupert wrote: > It appears I broke ggplot in my script, but that maybe it is because the > caffeine has worn off or maybe it is late in the day. I thought I was > beginning to understand ggplot, but I have encountered a silly little issue. > > For some rea

Re: [R] Specifying the gap between "dodge'd" bins groups?

2009-02-02 Thread hadley wickham
> However, is there a way to programmatically to extract the bin size that > ggplot selected in order to be able to change this for multiple data sets? Well the default is 30 bins - i.e. range(x) / 30 - in practice you'd want to choose something a bit more informative! > Similarly, is there a way

Re: [R] Specifying the gap between "dodge'd" bins groups?

2009-02-02 Thread hadley wickham
Hi Jason, On Mon, Feb 2, 2009 at 9:10 AM, Jason Rupert wrote: > I'm looking at ggplot-static\position_dodge.html > > For ggplot(diamonds, aes(x=price, fill=cut)) + geom_bar(position="dodge") , > is it possible to specify the spacing between the dodge'd bin groupings? > > That is, I would like fo

Re: [R] error message with roxygen

2009-02-02 Thread hadley wickham
On Fri, Jan 30, 2009 at 3:49 AM, David Hajage wrote: > Hello useRs, > > I'm trying to use the Roxygen package. > > Here my code file : > #' A packge to check Roxygen's sanity > #' @name helloRoxygen-package > #' @docType package > NA > > And my R code to generate the package : > library(roxygen) >

Re: [R] Problems in Recommending R

2009-02-02 Thread hadley wickham
> We often get emails like the first in this thread that R could do with > an update on homepage design (I fully agree) ... but actually nobody > volunteers to do it. Hence, we still have what I did when the > worldwide number of R users was probably less than 1000. Well I've volunteered a couple

Re: [R] Defining plot colors based on a variable

2009-02-02 Thread hadley wickham
On Mon, Feb 2, 2009 at 8:56 AM, Andrew Singleton wrote: > Hi, I have been trying unsuccessfully to plot data using different colors > based on a variable within a subset of an imported file. The file I am > reading is about 2 lines long and has a column (in the example called > FILE) that cont

Re: [R] reshape with two time variables

2009-01-30 Thread hadley wickham
On Fri, Jan 30, 2009 at 5:57 PM, Neil Stewart wrote: > I have a data frame in wide format that I'd like to convert to long format. > For example, in wide format I have: > >id A1B1A1B2A2B1A2B2 > 1 1 400 475 420 510 > 2 2 390 500 4

Re: [R] Stacking data

2009-01-29 Thread hadley wickham
            27193   30949    V2 > > But i have 41 columns (age column + 40 individuals) > I have the following script but an error is thrown up > can anyone help, where am i going wrong > > zz <- read.csv("Filename.csv",strip.white = TRUE) Try this: install.packages("r

Re: [R] ggplot2 - how to change location / position of wind rose axis labels?

2009-01-29 Thread hadley wickham
Hi Darren, Sorry for taking so long to get back to you - my hard drive died and it's taking me a while to get up and running again of backups etc. One solution to your problem is to draw the axis labels yourself: labels <- data.frame(rrating = 1:10, count = 19000) awind + opts(axis.text.x =

Re: [R] Changing histogram stack in qplot

2009-01-28 Thread hadley wickham
Hi Jason, You'll need scale_fill_manual(values = c(low = "blue", middle = "black", high = "red")) See http://had.co.nz/ggplot2/scale_manual.html for more examples/details. Regards, Hadley On Wed, Jan 28, 2009 at 3:11 PM, Jason Rupert wrote: > I've been using qplot pretty successfully to gener

Re: [R] Newbie question about "grouping"

2009-01-28 Thread hadley wickham
On Wed, Jan 28, 2009 at 8:13 AM, Rixon, John C. wrote: > Hi folks: > > I am a SQL guy who just downloaded and installed R yesterday. I am > trying to evaluate some "complex" aggregations we are currently > performing with Syncsort (and have tried in Oracle) with R. I have > loaded data in a data

Re: [R] Grouping problem

2009-01-28 Thread hadley wickham
You might want to have a look at the plyr package, http://had.co.nz/plyr, which includes tools for performing this sort of grouping. Hadley On Wed, Jan 28, 2009 at 9:47 AM, venkata kirankumar wrote: > Hi all, > I have a problem with grouping like I have to give count of employes in each > depart

Re: [R] Getting data from a PDF-file into R

2009-01-26 Thread hadley wickham
On Mon, Jan 26, 2009 at 9:40 AM, Peter Dalgaard wrote: > joe1985 wrote: >> Hello >> >> I have around 200 PDF-documents, containing data i want organized in R as a >> dataframe. The PDF-documents look like this; >> >> http://www.nabble.com/file/p21667074/PRRS-billede%2Bmed%2Bfarver.jpeg >> >> or

Re: [R] Plot, lines and disordered x and y

2009-01-23 Thread hadley wickham
>> >> This is of course minor (actually asymptotically, no annoyance at >> all). I am just mentioning it for 'completness' sake and because a >> divinely ideal plotting function should cope with data given in any >> order. >> > > The problem here is that a divinely ideal plotting function > for o

Re: [R] ggplot2 example

2009-01-23 Thread hadley wickham
> As I recall that is a known bug in the current version of ggplot2. That's right - because of an underlying bug in R which will be fixed in the next release of R and worked around in the next release of ggplot2. Hadley -- http://had.co.nz/ __ R-hel

Re: [R] Does anyone has this paper in pdf?

2009-01-23 Thread hadley wickham
On Wed, Jan 21, 2009 at 4:45 PM, wrote: > de Jong, S. (1993) SIMPLS: an alternative approach to partial least squares > regression. Chemometrics and Intelligent Laboratory Systems, 18, 251–263 Learn to use interlibrary loan: http://www.lib.iastate.edu/services1/ill_info.html Hadley -- http:/

Re: [R] trouble converting an array to a dataframe

2009-01-22 Thread hadley wickham
On Thu, Jan 22, 2009 at 9:09 AM, Christopher W. Ryan wrote: > I probably did not explain my data clearly. I am starting with a > dataframe with three columns: > > redlognumb radiologistbarrtotal > > where the entries in the variable radiologist are either 1 or 2, > indicating which radiolo

Re: [R] melt stumbles over deleted columns

2009-01-22 Thread hadley wickham
On Thu, Jan 22, 2009 at 8:01 AM, Titus von der Malsburg wrote: > I have a data frame that is the result of a cast (reshape) operation. I > deleted the variable column and tried to melt the resulting data frame. > Depending on which method I use to delete the column I get different > error message

Re: [R] trouble converting an array to a dataframe

2009-01-21 Thread hadley wickham
On Tue, Jan 20, 2009 at 11:10 PM, Christopher W. Ryan wrote: > I start with a dataframe called xrays. It contains scores on films from > each of two radiologists. It is in "long" format. I used the reshape > package to melt a data frame and then cast it into "wide" format, one > line for each pati

Re: [R] creating a list of matrices or data frames

2009-01-20 Thread hadley wickham
On Tue, Jan 20, 2009 at 10:34 AM, Simon Pickett wrote: > Hi all, > > How would you create a list of data.frames within a loop, then bind all the > elements of the list using rbind? > > take this example of matrices with differing numbers of rows > > for(i in 1:3){ > assign(paste("s",i, sep=""),mat

Re: [R] Stacked barplot with two stacked bars besides each other

2009-01-20 Thread hadley wickham
On Tue, Jan 20, 2009 at 4:28 AM, Daniel Brewer wrote: > Hi, > > I have a particular barplot I would like to generate, but I am having > trouble getting it to work. What I would like is in effect two barplots > with stacked bars merged into one. For example, I have two samples > (yoda1,yoda2) o

Re: [R] Bar Plot ggplot2 Filling bars with cross hatching

2009-01-20 Thread hadley wickham
>>I disagree. Grey levels suck; labels are a kludge. It is an issue >>for ``many'' == 2, for which crosshatching works perfectly. >> > > Could you show an example? > > There are several BW examples in example(barplot), and the gray ones look > better on screen than the cross-hatch

Re: [R] lattice question: independent per-row or per-column scaling?

2009-01-19 Thread hadley wickham
On Thu, Jan 8, 2009 at 11:25 AM, René J.V. Bertin wrote: > Hello - and happy newyear to all of you! > > I've got some data that I'm plotting with bwplot, a 3x2x3 design where > the observable decreases with the principle independent factor, but at > different rates. > > I'd like to get lattice to

Re: [R] Faster Printing Alternatives to 'cat'

2009-01-17 Thread hadley wickham
On Sat, Jan 17, 2009 at 7:59 AM, gundalav wrote: > Dear Jim and all, > > Allow me to ask your expert opinion. > > > Using the data (16Mb) downloadable from here: > > http://drop.io/gundalav/asset/test-data-zip > > > It took this long under 1994.070Mhz Cpu Linux, using > "write.table" > >> proc.tim

Re: [R] Bar Plot ggplot2 Filling bars with cross hatching

2009-01-15 Thread hadley wickham
This will be fixed in the next version, but until then you can do title = "Aquarium\n" Hadley On Wed, Jan 14, 2009 at 9:24 PM, stephen sefick wrote: > Also notice that the q in Aquarium is hidden. Is there a way to make > this not happen? > thanks > > Stephen Sefick > > On Wed, Jan 14, 2009 at

Re: [R] Bar Plot ggplot2 Filling bars with cross hatching

2009-01-15 Thread hadley wickham
Hi Stephen, > #I am putting a test together for an introductory biology class and I > would like to put different cross hatching inside of each bar for the > bar plot below ggplot2 uses the grid package to do all the drawing, and currently grid doesn't support cross-hatching, so unfortunately the

Re: [R] List of Lists

2009-01-14 Thread hadley wickham
On Wed, Jan 14, 2009 at 1:53 PM, glenn wrote: > Dear All; > > Is it possible to create a list of lists (I am sure it is) along these > lines; > > I have a dataframe data02 that holds a lot of information, and the first > column is ³date² > > I have a list of dates in; > > data03<-c(date1,.,dat

Re: [R] Casting lists to data.frames, analog to SAS

2009-01-14 Thread hadley wickham
> General Question: I assume the answer to the specific question is dependent > on my understanding list objects and accessing their attributes. Can anyone > point me to a good, throrough treatment of these R topics? Specifically how > to read and interpret the output of the str(), and attributes

Re: [R] reshape, direction=long: "multiple row names not allowed"

2009-01-14 Thread hadley wickham
On Wed, Jan 14, 2009 at 5:51 AM, Gustaf Rydevik wrote: > Hi all, > > for some reason I always get stuck spending hours when trying to use > reshape or the Reshape package. Heaven knows why. > My latest frustration (in 2.7.1, so ignore if this has been fixed): > > test<-data.frame(matrix(rnorm(42*4

Re: [R] Fw: Re: R Stacked Histogram

2009-01-10 Thread hadley wickham
ot. Instead of being outside the > plot, is it possible to move the location of the legend to the upper left or > right corner of the plot? Could you possibly provide an example. > > Thank you again for your feedback and insights. > > --- On Wed, 1/7/09, hadley wickham wrote: > &

Re: [R] Ashlee Vance's article on R in the New York Times

2009-01-09 Thread hadley wickham
> comparable to S-Plus and SAS, not withstanding Milley's snide comment. But > if you want to attack the chronic and painful productivity problems with > data preparation and statistical table production, you need to go beyond R > and SAS. What are these problems? Hadley -- http://had.co.nz/ _

Re: [R] R Stacked Histogram

2009-01-08 Thread hadley wickham
> # Unfortunately due to a small bug in the current version of ggplot, > you need to use > # jpeg with an e to get jpegs > ggsave(file = "ggsave_qplot_output.jpeg") > > # But I'd recommend using png instead - much better quality > ggsave(file = "ggsave_qplot_output.png") Here's a cute illustration

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

2009-01-08 Thread hadley wickham
On Thu, Jan 8, 2009 at 5:40 AM, retama wrote: > > Hi! > > I have been working several years with R but it's my first public question. > I hope I'll be clear :) . > > This question is related to obtaining letter-based representation of > non-parametric pairwise comparisons. > > I have a dataframe w

Re: [R] R in the NY Times

2009-01-07 Thread hadley wickham
> You might want to remove the 2009 data from each of the three lists > given that the January data is not yet complete. > > The result of including the January 2009 data in your plots is that the > growth trajectory for the smoothed curves for SAS-L and R-Help appear to > be leveling or even decli

Re: [R] Plotting a graph for every Level of a Factor

2009-01-07 Thread hadley wickham
On Wed, Jan 7, 2009 at 5:10 PM, jimdare wrote: > > Hello, > > Using the dataset below, is there a way to generate a bar/line plot for the > TACC/Catch of every lvl of stock? i.e. OR1,OR3,OR5. The picture at the > bottom of this post is an example of the bar/line plot for OR1 which was > generate

Re: [R] R in the NY Times

2009-01-07 Thread hadley wickham
Here's a couple of similar plots created with ggplot2. I chose to turn the data into a data frame with an explicit date column. Using a log scale somewhat stabilises the variability. ## SAS-L traffic sas <- structure(list(Jan = c(NA, 546L, 548L, 853L, 1007L, 894L, 514L, 1720L, 1826L, 1941L, 1832

Re: [R] Fw: Re: R Stacked Histogram

2009-01-07 Thread hadley wickham
Hi Jason, > Well, one last questions about stack plot (please forgive the lame example > below). I thought the below allow me to resize the the "title" of the > stacked histogram, but no luck. Any suggestions as to the modificaiton > necessary to get it to work? Right now the title is obscured

Re: [R] Problem with ggplot2 - facet_wrap and boxplot

2009-01-07 Thread hadley wickham
Hi David, > Here the problem : > > library(ggplot2) > > df <- data.frame(id = 1:100, x1 = c(rnorm(50), rnorm(50, 1)), x2 = > c(rnorm(50), rnorm(50, 1.5)), x3 = c(rnorm(50, 0.5), rnorm(50, 2.5)), group > = as.factor(rep(c("a", "b"), each = 50))) > df.melt <- melt(df, id = c("id", "group")) > head(d

Re: [R] R Stacked Histogram

2009-01-07 Thread hadley wickham
On Wed, Jan 7, 2009 at 7:55 AM, Jason Rupert wrote: > That worked! Thank you very much for the help. > > I think I have one last question about qplot in ggplot2, That is exporting > the plot to JPG while in a loop. I tried what was recommended in "Re: [R] > jpeg() creating empty files with qp

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

2009-01-05 Thread hadley wickham
> Another application of that technique can be used to quickly compute > medians by groups: > > gm <- function(x, group){ # medians by group: > sapply(split(x,group),median) > o<-order(group, x) > group <- group[o] > x <- x[o] > changes <- group[-1] != group[-length(group)] > first <- whi

Re: [R] R Stacked Histogram

2009-01-05 Thread hadley wickham
On Sun, Jan 4, 2009 at 6:51 PM, Jason Rupert wrote: > Understood. Will head the warning about odd way to display data. > > Any recommendations about where I look to find full details about "qplot". > > I tried ?qplot, but it did not return full details. > > That description was missing a few item

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

2009-01-04 Thread hadley wickham
>> easy to understand. Another approach is more specialized but useful >> when you have lots of ID's (e.g., millions) and speed is very important. >> It computes where the first and last entry for each ID in a vectorized >> computation, akin to the computation that rle() uses: > > I particularly t

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

2009-01-04 Thread hadley wickham
>> library(plyr) >> >> # ddply is for splitting up data frames and combining the results >> # into a data frame. .(ID) says to split up the data frame by the > subject >> # variable >> ddply(DF, .(ID), function(one) with(one, y[length(y)] - y[1])) >> ... > > The above is much quicker than the vers

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread hadley wickham
On Sat, Jan 3, 2009 at 12:37 PM, Ajay Shah wrote: >> As for jit and Ra, that was immediate reaction too but I found that jit does >> not help on your example. But I concur fully with what Ben said --- use the >> tool that is appropriate for the task at hand. If your task is running for >> loops,

Re: [R] R Stacked Histogram

2009-01-03 Thread hadley wickham
On Fri, Jan 2, 2009 at 11:00 PM, Jason Rupert wrote: > I've seen this asked, but never fully answered. > > Is it possible to plot stacked histograms in R? > > I have four data sets that I would like to show combined vertically in > histogram format. > > Is this possible? Yes, but it's generally

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