[R] How to add rowSums into list?
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Fri Jan 11 17:07:27 CET 2008
Lauri Nikkinen wrote:
> Thanks, one further question: how to order these matrices using these row sums?
>
> lapply(a, function(x) order(x[,5])) #produces only indeces
>
>
lapply(a, function(x) x[order(x[,5]),])
> -Lauri
>
> 2008/1/11, Henrique Dallazuanna <wwwhsd at gmail.com>:
>
>> lapply(a, addmargins, 2)
>>
>> On 11/01/2008, Lauri Nikkinen <lauri.nikkinen at iki.fi> wrote:
>>
>>> Hi R-users,
>>>
>>> I have a list
>>>
>>> a <- list(one=matrix(rnorm(20), 5, 4), two=matrix(rnorm(20, 3, 0.5),5,4))
>>>
>>> How to add rowSums (calculated using lapply) to corresponding matrix
>>> in this list
>>>
>>> lapply(a, function(x) rowSums(x))
>>>
>>> ??
>>>
>>> -Lauri
>>>
>>> ______________________________________________
>>> 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.
>>>
>>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>>
>
> ______________________________________________
> 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.
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list