[R] apply function to named numeric object
David Winsemius
dwinsemius at comcast.net
Mon Aug 3 15:31:52 CEST 2009
On Aug 3, 2009, at 9:07 AM, Paulo Eduardo Cardoso wrote:
> Maybe a very basic question.
> How can I get mean of a object like this
>
>> str(object)
> num [1:53, 1:2] 734 734 736 734 736 ...
> - attr(*, "dimnames")=List of 2
> ..$ : NULL
> ..$ : chr [1:2] "x" "y"
>
> I want the mean of both x and y
apply(object, 2, mean)
or...
colMeans(object) # which will be faster
> _______________
> Paulo E. Cardoso
>
> [[alternative HTML version deleted]]
>
> __________________________________________
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list