[R] tabulate means & NA
Christian Schulz
c.schulz at metrinomics.de
Thu Jun 20 11:33:06 CEST 2002
... uups embarrassingly
Thanks !
C.
Peter Dalgaard BSA wrote:
>Christian Schulz <c.schulz at metrinomics.de> writes:
>
>>Hi,
>>i have some problems to get means, but the data have got
>>NA's which should not be replaced or delete !
>>
>>tapply(data,var,mean) # makes me problem,because when one value is
>>NA mean is NA,too.
>>
>>Another attempt is this, because the summary does what i want , but
>>is not subsetable to summary[4] if i use tapply,table and the the
>>function below gives me
>>again all means as NA ?
>>
>> xmean <- function (var) {
>> summary(var)[4] }
>> apply(data,2,xmean) Thanks for any suggestion & regards,Christian
>>
>
>tapply(data,var,mean, na.rm=TRUE)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20020620/21fc1379/attachment.html
More information about the R-help
mailing list