I\'m trying to divide each number within a data frame with 16 columns by a specific number for each column. The numbers are stored as a data frame with 1-16 corresponding to
Suppose we have a dataframe, df:
df
> df a b c 1 1 3 100 2 2 4 110
And we want to divide through each row by the same vector, vec:
vec
> vec <- df[1,] > vec a b c 1 1 3 100
Then we can use mapply as follows:
mapply
> mapply('/', df, vec) a b c [1,] 1 1.000000 1.0 [2,] 2 1.333333 1.1