[R] dividing values of each column in a dataframe

Abhishek Pratap abhishek.vit at gmail.com
Mon Feb 6 20:22:53 CET 2012


Hey Guys

I want to divide(numerically) all the columns of a data frame by
different numbers. Here is what I am  doing but getting a weird error.
The values in each column are not getting divided by the corresponding
value in the denominator vector instead by the alternative values. I
am sure I am messing up something.

Appreciate your help
-Abhi

head(counts)
               WT_CON WT_RB MU_CON MU_RB
row1       839   180    477   187


head(counts/c(2,3,4,5))
               WT_CON    WT_RB    MU_CON    MU_RB
row1      419.50000  45.0000  238.5000  46.7500



More information about the R-help mailing list