Trying to use dplyr to group_by and apply scale()

前端 未结 2 616
广开言路
广开言路 2020-12-05 23:54

Trying to use dplyr to group_by the stud_ID variable in the following data frame, as in this SO question:

> str(df)         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 00:20

    This was a known problem in dplyr, a fix has been merged to the development version, which you can install via

    # install.packages("devtools")
    devtools::install_github("hadley/dplyr")
    

    In the stable version, the following should work, too:

    scale_this <- function(x) as.vector(scale(x))
    

提交回复
热议问题