similar to: weighted.mean and tapply (again)

Displaying 20 results from an estimated 3000 matches similar to: "weighted.mean and tapply (again)"

2005 May 26
0
R: weighted.mean and tapply (again)
what about using "mapply"? splitted.value<-with(x.1, split(VALUE, GROUP)) splitted.freq<-with(x.1, split(FREQUENCY, GROUP)) mapply(weighted.mean, splitted.value, w=splitted.freq) Stefano >-----Messaggio originale----- >Da: r-help-bounces at stat.math.ethz.ch >[mailto:r-help-bounces at stat.math.ethz.ch]Per conto di >james.holtman at convergys.com
2005 Jul 05
1
Invalid device number in savePlot
Hi, I recently encountered an error using the command "savePlot" when trying to save the third of 3 open graph windows. After successfully saving and closing the first two windows I receive an "Invalid device number in savePlot" error. The following is copied and pasted from an example session to illustrate the behaviour: > windows() > hist(rnorm(100)) > windows()
2005 Aug 03
2
using weighted.mean with tapply()
I am trying to calculate the weighted mean for a of 10 deciles and I get an error: > decile <- tapply(X=mat$trt1m, INDEX=mat$Rank, FUN=weighted.mean, w=mat$mcap) Error in FUN(X[[1]], ...) : 'x' and 'w' must have the same length All three of my inputs have the same length, as shown below, and the weighted.mean calculation works by itself, just not in tapply() >
2006 Jan 12
2
tapply and weighted means
I' m trying to compute weighted mean on different groups but it only returns NA. If I use the following data.frame truc: x y w 1 1 1 1 2 2 1 3 1 1 4 2 0 2 1 0 3 2 0 4 1 0 5 1 where x is a factor, and then use the command : tapply(truc$y,list(truc$x),wtd.mean, weights=truc$w) I just get NA. What's the problem ? What can I do ?
2003 Jul 31
1
help with tapply and weighted.mean
Hello! I have data frame with 'weights' in one of the columns. I need to compute weighted mean on another column other factor variable and i am trying to: res<-tapply(data$k,list(data$model),weighted.mean,w=data$w,na.rm=T) and i get: Warning messages: 1: longer object length is not a multiple of shorter object length in: x * w 2: longer object length is not a multiple of shorter
2005 Jan 26
0
tapply with weighted.mean
We were caught out recently attempting to use tapply to get a table of weighted means. This gives the wrong answer (or, more correctly, not the answer we were expecting), as the following example shows: R> x <- 1:10 #some data R> w <- c(1:5,5:1) #weights R> id <- rep(1:2,rep(5,2)) #id values R> weighted.mean(x[id==1],w[id==1]) #Weighted mean of x in group 1 [1] 3.666667
1999 Nov 25
0
tapply and weighted.mean
I am trying to use tapply to estimate the average wage in a set of Year*Education cells using sampling weights, as well as some other other statistics using the weights). I am having trouble trying to figure out how to pass the weights to the function, using: > tapply(wage,list(Educc,Year),weighted.mean, w=weight) whieh produces warnings of the type: 3: longer object length is not a
2005 Jun 06
6
Strange characters in 2.1.0?
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Signif. codes: 0 <80><98>***<80><99> 0.001 <80><98>**<80><99> 0.01 <80><98>*<80> <99> 0.05 <80><98>.<80><99> 0.1 <80><98> <80><99> 1 Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 hmm... they go away when I
2009 Oct 08
2
lattice: passing multiple lty values to the key/legend
hi all, It's not clear to me how (or if) I can pass multiple values for lty to a key in xyplot? I've tried: lines=list(lty=1:3), to no avail. Do I need to use something other than auto.key? (Deepayan, if you're out there, I have your book and must admit the answer isn't jumping out at me.) thanks in advance! Michael Folkes example code: #____________________________
2013 Sep 09
1
Hmisc binconf function value interpretation during narrow confidence intervals
Hello all, I've been using binconf (package Hmisc) at a range of alpha values and noticed that using the 'Wilson' method when alpha is larger (i.e. narrow CI), results in the upper value being smaller than the lower value. The 'exact' and 'asymptotic' methods give results in the realm I'd expect. But the help file suggests: "Following Agresti and Coull, the
2004 Nov 03
4
Legend placement in barplot?
This has been asked before, but all the answers are hidiously complex. The legend.text=TRUE option of barplot is almost exactly what I need, except I need a legend.placement='tl' (top left) option. This option would be in contrast to the default placement which we could call 'tr' (top right). Anyone know how to edit the barplot code to make this change? Could someone like me
2005 Jun 06
9
R Graph Gallery : categorization of the graphs
Hello all, It seems that the next improvement to the R Graph Gallery is categorization of the graphics, that way each graph will be easier to find. That step should be done *carefully* if we want to avoid the opposite side-effect : graph not reachable through the categories. That's why the wisdom of the R community is required. Graphics will be classified in : - categories -
2004 Nov 04
4
highly biased PCA data?
Hello, supposing that I have two or three clear categories for my data, lets say pet preferece across fish, cat, dog. Lets say most people rate their preference as being mostly one of the categories. I want to do pca on the data to see three 'groups' of people, one group for fish, one for cat and one for dog. I would like to see the odd person who likes both or all three in the
2005 Jan 07
4
hist function to give each cell equal area
Hi, I want to use hist with non-equi-spaced breaks, picked such that the fraction of the data points falling in the cells (defined by 'breaks') is roughly equal accross all cells. Is there such a function that will automatically try to determine the breaks to fullfill this requirement? Something like.. hist( x, br = magic_function_to_pick_breaks()) For example, if x looked like
2005 Jan 04
3
Adding values to the end of a vector?
I want to add values onto the end of a vector, for example... x <- vector for (i in 1:5){ add_to_end_of_vector(i,x) } I just cant find the answer to this question! Sorry for such a basic question, I tried... x <- c() for (i in 1:5) x[length(x)] <- i but it didn't work.
2004 Nov 04
2
Bug report (PR#7341)
Full_Name: Dan B Version: na OS: na Submission from: (NULL) (80.6.127.185) I can't log into the bug tracker (I can't find where to register / login). In this way I can't add the following context diff (hopefully in the right order) for my changes to the matrix.Rd... Hmm... I guess this should be a separate report anyway... The first diff explains how the dimnames list should
2005 Feb 18
4
barplot and ylim - display problems
The following single line of code shows what I am trying to do, and the problem I am having... barplot(c(101,102,103),ylim=c(100,103)) The 'xaxis' is missing, and the grey bars 'fall off' the plot area. This is generally ugly, and I would like to trim the bars (ideally they would have a ragged appearance to show that I am 'zooming in'). I can see why what I am trying to
2004 Mar 17
2
Installing Samba
Hi I am trying to install Samba on a QNX 4.24 system. When we run the make file we get an error : compiling server.c make:cc:command not found make: *** [server.o] error 127 Can you help with this! Lucille Shears Systems Analyst CCG/DFO shearsl@dfo-mpo.gc.ca (709) 772-3131 cell (685-1512)
2011 Mar 04
4
Floating points and floor() ?
Perhaps somebody could clarify for me if the following is a floating point matter or otherwise, and how am I to correct for it? > floor(100*.1) [1] 10 > 100*(1.0-.9) [1] 10 > floor(100*(1-0.9)) [1] 9 Thanks! Michael _______________________________________________________ Michael Folkes Salmon Stock Assessment Canadian Dept. of Fisheries & Oceans Pacific Biological Station
2007 Jun 20
2
Retrieve part of (top right corner) of a "plot.data.frame" plot?
Hi, I believe this question has been asked before, but I cant find and don't remember the answer. The problem is simple, calling 'plot.data.frame(x)' gives a nice 'matrix of scatterplots' for each pair of columns in x. for example; x <- data.frame(a=jitter(01:20), b=jitter(20:01), c=jitter(21:40), d=jitter(rep(01,20)),