Created
August 4, 2021 10:33
-
-
Save cbrown5/56bd58e5ff82ba0c06e813a625a7268c to your computer and use it in GitHub Desktop.
scale numeric variables in a data.frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Apply scale to just numeric variables | |
#keep all variables | |
dat2 <- dat %>% | |
mutate(across(where(is.numeric), scale)) | |
#keep just numerical variables, drop the others from the data.frame | |
dat2 <- dat %>% | |
transmute(across(where(is.numeric), scale)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment