Re: [R] to divide column cells by the mean of another column

2014-04-20 Thread arun
Hi Andre, A slight correction: fun1 <- function(beginColumn, by, data) {     indx <- seq(beginColumn, ncol(data), by = by)     dataNew <- data[, indx[1]:ncol(data)]     indx1 <- cumsum(seq(ncol(data)) %in% indx)     indx2 <- indx1[indx1 != 0]     lst1 <- lapply(split(seq_along(indx2), indx2), fun

Re: [R] to divide column cells by the mean of another column

2014-04-20 Thread arun
Hi, May be this helps: fun1 <- function(beginColumn, by, data) {     indx <- seq(beginColumn, ncol(data), by = by)     dataNew <- data[, indx[1]:ncol(data)]     indx1 <- cumsum(seq(ncol(data)) %in% indx)     indx2 <- indx1[indx1 != 0]     lst1 <- lapply(split(seq_along(indx2), indx2), function(i)

Re: [R] to divide column cells by the mean of another column

2014-04-20 Thread Bert Gunter
R has no "cells". You need to do your homework by reading "An Introduction to R" , which ships with R, or one of the many R web tutorials of your choice. What you describe is trivial once you have made a minimal effort to learn R. In particular, ?"[" explains how to index data frames; but a tutor

[R] to divide column cells by the mean of another column

2014-04-20 Thread Andre Zacharia
Dear all, I am getting data columnwise that I need to divide by the mean of another column If the column is the previous one this code works perfectly well: fun1 <- function(beginColumn, by, data) { indx <- seq(beginColumn, ncol(data), by = by) as.data.frame(t(100 - (t(data[, indx])/colMeans(dat