[R] how to print global index from tapply function?
David Winsemius
dwinsemius at comcast.net
Sat Jun 9 04:44:45 CEST 2012
On Jun 8, 2012, at 4:22 PM, Angelr wrote:
> Hi, the global row indexing for my cluster assignment is as :
>
> buf <- tapply(test1, test2, FUN = function(x){x;})
> $`1`
> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> $`2`
> [1] 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
>
> I used "tapply" function to find minimum as:
>> foo <- tapply(dist, test2, FUN = which.min)
> which prints:
> 1 2
> 16 17
>
> I want it to print the miminum based on global row indexing as:
> 1 2
> 16 77
>
> How can I get to print the actual entry instead of re-counted entry?
> Any
> help? Thanks.
The row.names might get carried accross. If not then you could use an
lapply(split(.)) strategy. Not tested in absence of example.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list