On Mar 26, 2013, at 6:50 PM, Michael Budnick wrote:

> I am working on a gene expression microarray dataset, each sample has been 
> taking from animal A and animal B on the same type of microarray.
> 
> I would like to take the mean of these columns and create a dataset with 
> columns with data which are means of the corresponding rows of A and B
> 
> For example:
> 
> TissueExpressionA <- HTissue[1:22284, c(29, 39, 57, 59, 63, 69, 71, 73, 77, 
> 79, 83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159)]
> TissueExpressionB <- HTissue[1:22284, c(30, 40, 58, 60, 64, 70, 72, 74, 78, 
> 80, 84, 90, 100, 118, 120, 122, 124, 126, 138, 146, 160)]
> 
> 
> I would like
> 
> TissueExpressionC <- HTissue[1:22284, c[mean(29,30), mean(39,40), mean(57,58) 
> ... mean(159,160)]
> 

mean(29,30) will evaluate to 29.5 which would have picked out a single column

allmeans <- colMeans(HTissue[1:22284, sort( c(30, 40, 58, 60, 64, 70, 72, 74, 
78, 80, 84, 90, 100, 118, 120, 122, 124, 126, 138, 146, 160), c(29, 39, 57, 59, 
63, 69, 71, 73, 77, 79, 83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159))  ]
# I do not see a pattern in this pairing.
# Will return a vector rather than a data.frame.

len <- length( sort( c(30, 40, 58, 60, 64, 70, 72, 74, 78, 80, 84, 90, 100, 
118, 120, 122, 124, 126, 138, 146, 160), c(29, 39, 57, 59, 63, 69, 71, 73, 77, 
79, 83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159))  )

sapply(seq(1, len-1, by=2), function(colA) mean( c(allmeans[colA:(colA+1)]) ) )
#should return a vector that is half the length of len

Testing not done in the absence of data.


> 
> I hope that makes sense.

Perhaps.

> 
> If you know of any other method of merging data sets like this any help would 
> be appreciated.
> 
> Michael Budnick
> Graduate Researcher
> St. John's University
> 
>       [[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.

David Winsemius
Alameda, CA, USA

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

Reply via email to