Hi there. newby here...
I am trying to create a new data set where I have replaced the values in all rows for certain columns by applying a function to them. Ive done this with this code
df_new = as.data.frame(t(apply(df[c(3:5)], 1, function(x) x/sum(x))))
so dividing each cell in columns 3,4,5 by the summation of the rows of 3,4,5.
This works fine. However, I have now lost all of my other columns in the data set. some with string value others with numerical value. any help would be much appreciated.