Re: [R] Using summaryBy with weighted data

2011-01-17 Thread Sebastián Daza
Hi everyone, I am trying to run Sweave.bat (batchfiles_0.6-1) from the command line on Windows, but I get this error: C:\batchfiles_0.6-1>Sweave.bat Sweave-test-1 "Error: rterm.exe not found" I don't know how to set up the path if this one were the problem... I ran rcmd.bat and I got this...

Re: [R] Using summaryBy with weighted data

2011-01-17 Thread Solomon Messing
Thanks Dennis, looks like there's even less boiler plate code with plyr. By the way, what I labelled "W.SE" is meant to represent the weighted standard error of the mean. Your "WSE" calculations appear to be providing the weighted standard deviation of the variable. Is this a matter of needin

Re: [R] Using summaryBy with weighted data

2011-01-17 Thread Søren Højsgaard
It is currently not possible to pass weights in summaryBy. Regards Søren Fra: Joshua Wiley [jwiley.ps...@gmail.com] Sendt: 17. januar 2011 08:16 Til: Solomon Messing Cc: r-help@r-project.org; Søren Højsgaard Emne: Re: [R] Using summaryBy with weighted

Re: [R] Using summaryBy with weighted data

2011-01-17 Thread Dennis Murphy
Hi: Does this do what you need? wstats <- function(d) { require(Hmisc) N <- length(d$response[!is.na(d$response)]) c(WM = wtd.mean(d$response, d$weights), WSE = sqrt(wtd.var(d$response, d$weights)), N = N) } library(plyr) dd

Re: [R] Using summaryBy with weighted data

2011-01-17 Thread Solomon Messing
Thanks Josh. I built on your example and ended up with the code below--if you or anyone sees any issues please let me know. It would be great if there were a slicker way to get these kinds of summary stats in R, but this gets the job done. # takes data frame z with weights w and data x, retur

Re: [R] Using summaryBy with weighted data

2011-01-17 Thread David Freedman
You might use the plyr package to get group-wise weighted means library(plyr) ddply(mydata,~group,summarise, b=mean(weights), c=weighted.mean(response,weights)) hth david freedman -- View this message in context: http://r.789695.n4.nabble.com/Using-summaryBy-with-weighted-data-tp3220761p32212

Re: [R] Using summaryBy with weighted data

2011-01-16 Thread Joshua Wiley
Dear Solomon, On Sun, Jan 16, 2011 at 10:27 PM, Solomon Messing wrote: > Dear Soren and R users: > > I am trying to use the summaryBy function with weights.  Is this possible?   > An example that illustrates what I am trying to do follows: > > library(doBy) > ## make up some data > response = rno

[R] Using summaryBy with weighted data

2011-01-16 Thread Solomon Messing
Dear Soren and R users: I am trying to use the summaryBy function with weights. Is this possible? An example that illustrates what I am trying to do follows: library(doBy) ## make up some data response = rnorm(100) group = c(rep(1,20), rep(2,20), rep(3,20), rep(4,20), rep(5,20))