Skip to content
Prev 320374 / 398506 Next

Creating mean C columns out of As and Bs

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

            
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.
Perhaps.
David Winsemius
Alameda, CA, USA