Re: [R] getting a weighted average from a table

2010-05-07 Thread Phil Spector
dat = c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) tt = table(dat) sum(as.numeric(names(tt))*tt)/ sum(tt) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] getting a weighted average from a table

2010-05-07 Thread SHANE MILLER, BLOOMBERG/ 731 LEXIN
Hi, I have a very simple request (I think). I have a vector/array, > c <- c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) I produce a reverse sorted table/histogram with it, > t = rev(sort(table(c)) > t c 3.3 1.2 5.1 1.3 1.1 1 0 2 2 1 1 1 1 1 I would now like to get the labe

Re: [R] getting a weighted average from a table

2010-05-07 Thread David Winsemius
On May 7, 2010, at 9:42 AM, SHANE MILLER, BLOOMBERG/ 731 LEXIN wrote: Hi, I have a very simple request (I think). I have a vector/array, c <- c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) I produce a reverse sorted table/histogram with it, t = rev(sort(table(c)) t c 3.3 1.2 5.1 1.3 1.1 1 0

Re: [R] getting a weighted average from a table

2010-05-07 Thread SHANE MILLER, BLOOMBERG/ 731 LEXIN
Hi, I have a very simple request (I think). I have a vector/array, > c <- c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) I produce a reverse sorted table/histogram with it, > t = rev(sort(table(c)) > t c 3.3 1.2 5.1 1.3 1.1 1 0 2 2 1 1 1 1 1 I would now like to get the labe