I have 100 non-negative columns in my dataframe and would like to create the log transformation of each of them in R. How do I accomplish this? I'd ideally like to retain the original variables name and append the suffix "_log" to the new variables.

2

1 Answer

Just do

newdata <- log(data) 

You can then do something like (untested)

names(newdata) <- paste0(names(data), "_log") 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.