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(data[,
indx - 1], na.rm = TRUE)) *  100))
}
(Arun helped me with this code, thank you again!...)

But, the things is now more complicated...

I need to program a function that allow me to divide for example cells from
column 3 on mean from column 2 and cells from column 4 on mean of column 2
and the 5 etc. Then column 6 is another column from whch I  need to extract
the mean and to do the same with column 7 and 8, etc...

so if  I have:

1  2  3 4  1  5
2  5  4 7  2  8
3  4  5 9  3  7
4  7  7 9  4  3

The serie 1,2,3,4 ar just enumerating so not useful at this timepoint.

the results should be (from excel...):
 4,5 33,3333333 11,1111111 -11,1111111   11,1111111 -55,5555556 -77,7777778
-11,1111111 -100 -55,5555556   -55,5555556 -100
33,3333333
I tried to work on modyfying indx-1 by 2*indx-2, but this is not doing the
job... I tried many other things so that I am now stucked.

Does Anyone has a brilliant idea?

Many many thanks

André ZACHARIA

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

Reply via email to