Thanks. Works
A doubt.

I asked that because I have a loop that can generate objects like that or
this one


str(object)
Named num [1:2] 670 314
 - attr(*, "names")= chr [1:2] "x" "y"

To avoid using a ifelse() to calculate means of x and y, I'd like a function
that handle with this named numeric object and that list. Any chance of do
it with a single function?



2009/8/3 David Winsemius <dwinsem...@comcast.net>

>
> 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
>
>


-- 
_______________
Paulo E. Cardoso

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to