Re: [R] mean on a table

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 12 Jan 2007 - 01:35:01 GMT

Farrel Buchinsky wrote:
> Please suggest areas that I should troubleshoot. This command used to
> give me an answer and now it gives me an error.
>
>> mean(no.genot,na.rm=T)
>>
> Error in tapply(x, by, sum, na.rm = TRUE) :
> arguments must have same length
> I tried removing the na.rm=T)
>
>> mean(no.genot)
>>
> Error in `names<-.default`(`*tmp*`, value = c("by.1", "by.0")) :
> attempt to set an attribute on NULL
>
> The structure of my table is as follows.
>
>> str(no.genot)
>>
> table [, 1:467] 0.000 0.261 0.315 0.274 0.349 ...
> - attr(*, "dimnames")=List of 1
> ..$ : chr [1:467] "NC" "RP138" "RP139" "RP140" ...
>
> Strangely enough
>
>> mean(no.genot[1:467])
>>
> [1] 0.2426167
>
> That seems to work.
>
Have you perhaps a stray mean() or mean.table() function lying around?

Doesn't look like it would normally happen:

 > tb <- as.table(as.double(1:10))
 > str(tb)
 table [, 1:10] 1 2 3 4 5 6 7 8 9 10


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Jan 12 12:40:30 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 12 Jan 2007 - 04:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.