I want to sqrt all columns of my df except the first one which has chr = names in rstudio
When I code:
df2 <- sqrt(df[,-1])
it removes the first column of the df and than does sqrt.
I want to limit sqrt to do all columns but the first.
One option is to use lappy
df[,-1] <- lapply(df[,-1], sqrt)
Great, thank you.
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy