Re: [R] For applying formula in rows

2011-07-13 Thread Berend Hasselman
Bansal, Vikas wrote: Dear all, I have a problem and it is very difficult for me to get a code. I am reading a file(attached with this mail) using the code- df=read.table(summary.txt,fill=T,sep=,colClasses = character,header=T) and dataframe df is like this- V1V2 CaseA

[R] For applying formula in rows

2011-07-12 Thread Bansal, Vikas
Dear all, I have a problem and it is very difficult for me to get a code. I am reading a file(attached with this mail) using the code- df=read.table(summary.txt,fill=T,sep=,colClasses = character,header=T) and dataframe df is like this- V1V2 CaseA CaseC CaseG CaseT new 10

Re: [R] For applying formula in rows

2011-07-12 Thread Joshua Wiley
Hi Vikas, Here is one way: df - read.table(summary.txt, header = TRUE) str(df) df[, total] - rowSums(df[, 3:6]) df[, 3:6] - apply(df[, 3:6], 2, function(x) x / df[, total] * df[, new] * 2) head(df) V1V2 CaseA CaseC CaseG CaseT new total 1 10 135344109 0 024 0 12