Re: [R] How to add rowSums into list?

2008-01-11 Thread Henrique Dallazuanna
lapply(a, addmargins, 2)

On 11/01/2008, Lauri Nikkinen [EMAIL PROTECTED] 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@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@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.


Re: [R] How to add rowSums into list?

2008-01-11 Thread ONKELINX, Thierry
a - list(one=matrix(rnorm(20), 5, 4), two=matrix(rnorm(20, 3,
0.5),5,4))

lapply(a, function(x){
  cbind(x, rowSums(x))
})

Cheers,

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Lauri Nikkinen
Verzonden: vrijdag 11 januari 2008 14:09
Aan: [EMAIL PROTECTED]
Onderwerp: [R] How to add rowSums into list?

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

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


[R] How to add rowSums into list?

2008-01-11 Thread Lauri Nikkinen
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@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.


Re: [R] How to add rowSums into list?

2008-01-11 Thread Henrik Bengtsson
On 11/01/2008, Lauri Nikkinen [EMAIL PROTECTED] wrote:
 Thanks, one further question: how to order these matrices using these row 
 sums?

 lapply(a, function(x) order(x[,5])) #produces only indeces

...which you can use as row indices 'idxs' to reorder the rows of
matrix 'x' by x[idxs,].

/Henrik


 -Lauri

 2008/1/11, Henrique Dallazuanna [EMAIL PROTECTED]:
  lapply(a, addmargins, 2)
 
  On 11/01/2008, Lauri Nikkinen [EMAIL PROTECTED] 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@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@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.


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


Re: [R] How to add rowSums into list?

2008-01-11 Thread Peter Dalgaard
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 [EMAIL PROTECTED]:
   
 lapply(a, addmargins, 2)

 On 11/01/2008, Lauri Nikkinen [EMAIL PROTECTED] 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@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@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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] How to add rowSums into list?

2008-01-11 Thread Lauri Nikkinen
Thanks, one further question: how to order these matrices using these row sums?

lapply(a, function(x) order(x[,5])) #produces only indeces

-Lauri

2008/1/11, Henrique Dallazuanna [EMAIL PROTECTED]:
 lapply(a, addmargins, 2)

 On 11/01/2008, Lauri Nikkinen [EMAIL PROTECTED] 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@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@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.