Re: [R] row mean
Hi Eliza, No problem. You can also do: lst1 <- vector("list",12) for(i in seq_along(lst1)) lst1[[i]] <- colMeans(AAA[seq(i,nrow(AAA), by=12),]) A.K. On Wednesday, May 28, 2014 4:17 AM, eliza botto wrote: Thankyou very much dennis and arun, The codes worked as ever. :D Eliza > Date: Tue, 27 May 2014 18:43:44 -0700 > From: smartpink...@yahoo.com > Subject: Re: [R] row mean > To: r-help@r-project.org > CC: eliza_bo...@hotmail.com > > > > Forgot, about the mean: > lapply(split(seq_len(nrow(AAA)),((seq_len(nrow(AAA))-1)%%12)+1),function(i) > colMeans(AAA[i,])) > A.K. > > > On , arun wrote: > > > Hi Eliza, > May be this helps: > lapply(split(seq_len(nrow(AAA)),((seq_len(nrow(AAA))-1)%%12)+1),function(i) > AAA[i,]) > A.K. > > > > > > On Tuesday, May 27, 2014 6:48 PM, eliza botto wrote: > Dear R family, > I have this matrix say > AAA<-matrix(sample(1:240),ncol=2) > I first want to combine every 13th row in both columns. precisely, starting > from row-1 1,13,25,37,49, then starting from row-2 > 2,14,26,38,50 also 3,15,27,39,51 and similarly starting from row 4, row > number 5, row 6... till 12th row,for both columns. so in a way > we will have list of 12 matrices each with 10 rows and 2 columns. > Finally, I want to calculate mean of each column of each matrix in that list, > while keeping the integrity of the list intact. > Kindly Advice! > > Thankyou very much indeed in advance. > Eliza > > > [[alternative HTML version deleted]] > > __ > 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] row mean
Forgot, about the mean: lapply(split(seq_len(nrow(AAA)),((seq_len(nrow(AAA))-1)%%12)+1),function(i) colMeans(AAA[i,])) A.K. On , arun wrote: Hi Eliza, May be this helps: lapply(split(seq_len(nrow(AAA)),((seq_len(nrow(AAA))-1)%%12)+1),function(i) AAA[i,]) A.K. On Tuesday, May 27, 2014 6:48 PM, eliza botto wrote: Dear R family, I have this matrix say AAA<-matrix(sample(1:240),ncol=2) I first want to combine every 13th row in both columns. precisely, starting from row-1 1,13,25,37,49, then starting from row-2 2,14,26,38,50 also 3,15,27,39,51 and similarly starting from row 4, row number 5, row 6... till 12th row,for both columns. so in a way we will have list of 12 matrices each with 10 rows and 2 columns. Finally, I want to calculate mean of each column of each matrix in that list, while keeping the integrity of the list intact. Kindly Advice! Thankyou very much indeed in advance. Eliza [[alternative HTML version deleted]] __ 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] row mean
Hi Eliza, May be this helps: lapply(split(seq_len(nrow(AAA)),((seq_len(nrow(AAA))-1)%%12)+1),function(i) AAA[i,]) A.K. On Tuesday, May 27, 2014 6:48 PM, eliza botto wrote: Dear R family, I have this matrix say AAA<-matrix(sample(1:240),ncol=2) I first want to combine every 13th row in both columns. precisely, starting from row-1 1,13,25,37,49, then starting from row-2 2,14,26,38,50 also 3,15,27,39,51 and similarly starting from row 4, row number 5, row 6... till 12th row,for both columns. so in a way we will have list of 12 matrices each with 10 rows and 2 columns. Finally, I want to calculate mean of each column of each matrix in that list, while keeping the integrity of the list intact. Kindly Advice! Thankyou very much indeed in advance. Eliza [[alternative HTML version deleted]] __ 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] row mean
Dear R family, I have this matrix say AAA<-matrix(sample(1:240),ncol=2) I first want to combine every 13th row in both columns. precisely, starting from row-1 1,13,25,37,49, then starting from row-2 2,14,26,38,50 also 3,15,27,39,51 and similarly starting from row 4, row number 5, row 6... till 12th row,for both columns. so in a way we will have list of 12 matrices each with 10 rows and 2 columns. Finally, I want to calculate mean of each column of each matrix in that list, while keeping the integrity of the list intact. Kindly Advice! Thankyou very much indeed in advance. Eliza [[alternative HTML version deleted]] __ 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] Row mean scores differ
>Suppose that we have o 2-D contingency table where the row variable is nominal >and the column one is ordinal. In SAS it is possible to compute the statistic >named as row mean scores differ. How can we programmed it in R? >(See also Aggresti (2002), Categorical Data Analysis, p. 302) There is a chapter by chapter R / S-PLUS companion to Agresti (2002) by Laura Thompson at https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf HTH, Tobias __ 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] Row mean scores differ
Suppose that we have o 2-D contingency table where the row variable is nominal and the column one is ordinal. In SAS it is possible to compute the statistic named as row mean scores differ. How can we programmed it in R? (See also Aggresti (2002), Categorical Data Analysis, p. 302) With regards - [[alternative HTML version deleted]] __ 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] Row mean scores differ association
There is a R companion to Agresti's text at the following site, I believe the answer to your question is there: http://www.stat.ufl.edu/~aa/cda/cda.html --Matt Matt Austin Biostatistics Director Amgen, Inc -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of dt Excellent Sent: Thursday, April 10, 2008 1:18 PM To: R-Help Subject: [R] Row mean scores differ association Suppose that we have o 2-D contingency table where the row variable is nominal and the column one is ordinal. In SAS it is possible to compute the statistic named as row mean scores differ. How can we programmed it in R? (See also Aggresti (2002), Categorical Data Analysis, p. 302) With regards - [[alternative HTML version deleted]] __ 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] Row mean scores differ association
Suppose that we have o 2-D contingency table where the row variable is nominal and the column one is ordinal. In SAS it is possible to compute the statistic named as row mean scores differ. How can we programmed it in R? (See also Aggresti (2002), Categorical Data Analysis, p. 302) With regards - [[alternative HTML version deleted]] __ 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.