R - Scaling numeric values only in a dataframe with mixed types

后端 未结 3 1316
野的像风
野的像风 2021-01-04 01:28

I am working with a data frame that has mixed data types (numeric and character) and also has a character key as the primary identifier. I\'d like to scale and center the n

3条回答
  •  粉色の甜心
    2021-01-04 02:24

    Something like this should do what you want:

    library(MASS)
    ind <- sapply(anorexia, is.numeric)
    anorexia[ind] <- lapply(anorexia[ind], scale)
    

提交回复
热议问题