[R] tapply confusion

David Winsemius dwinsemius at comcast.net
Wed Aug 29 20:42:25 CEST 2012


On Aug 29, 2012, at 7:37 AM, andyspeak wrote:

> Hello
> I have a huge data frame with three columns 'Roof' 'Month' and 'Temp'
> i want to run analyses on the numerical Temp data by the factors  
> Roof and
> Month, separately and together.
> For using more than one factor i understand i should use aggregate,  
> but i am
> struggling with the tapply for single factor analysis.
>
>> tapply(Temp, INDEX = Roof, FUN = median)
>
> This works fine, however if i try to do anything a bit more complex,  
> such
> as:
>
>> tapply(Temp, INDEX = Roof, FUN = kruskal.test)
>
> it gives the error - Error in length(g) : 'g' is missing

What is the sound of one hand clapping?

You are sending a bunch of single vectors with no grouping variable to  
a function that is expecting two data columns. Maybe you should  
explain what test you had in mind using natural language and we could  
help get you there.


-- 
David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list