square root data transformation


is there a code one can use to transform several variables in R. I want to use square root transformation to transform more than 1 varible in r , i only know how i can transform single variable. code used for 1 variable is :
ArsnGP<- asin (sqrt(Stem$GP/100))

my question is if have more than 1 variable in data that has to be transformed,is there a code can use which will transform all variables at once than doing it individually?


Hi @pfarelo,
If you use the tidyverse packages, you might want to check out the documentation for the function across, which lets you apply a single function across multiple columns.

Your code might look something like:

transformedData <- oldData %>%
    mutate(across(c(GP, anotherColumn, yetAnotherColumn, 
                  function(x) asin(sqrt(x/100))

I hope that helps!

Thanks a lot ,

all methods works perfectly .appreciate

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.