[R] max number from a list of numbers
Erik Iverson
eriki at ccbr.umn.edu
Thu May 20 21:38:00 CEST 2010
You have a list that you want to treat as a vector, so ?unlist it.
Jonathan wrote:
> Hi all,
> I'm hoping this question has a simple answer, but I can't find it through
> searching or trying commands.
>
> I have a list of numeric vectors called 'husk'. I'd just like to treat the
> set of all numbers from all vectors in the list as if it were one large
> vector, because I'd like to extract information, such as what is the max
> entry from all the numbers.
>
>> husk
> [[1]]
> [1] 2 5
>
> [[2]]
> [1] 2 17
>
> [[3]]
> [1] 2
>
> [[4]]
> [1] 17
>
>> max(husk)
> Error in max(husk) : invalid 'type' (list) of argument
>
>> max(husk[])
> Error in max(husk[]) : invalid 'type' (list) of argument
>
>> max(husk[[]])
> Error in husk[[]] : invalid subscript type 'symbol'
>
>> max(husk[[1:length(husk)]])
> Error in husk[[1:length(husk)]] : recursive indexing failed at level 2
>
>> max(husk[1:length(husk)])
> Error in max(husk[1:length(husk)]) : invalid 'type' (list) of argument
>
> Any ideas would be appreciated!
>
> Best,
> Jonathan
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list