How does one stop using rowwise in dplyr?

后端 未结 3 445
你的背包
你的背包 2020-12-13 08:33

So, if one wishes to apply an operation row by row in dplyr, one can use the rowwise function, for example: Applying a function to every row of a table using dp

3条回答
  •  半阙折子戏
    2020-12-13 09:11

    Just use ungroup()

    The following produces a warning:

    data.frame(a=1:4) %>% rowwise() %>% 
      group_by(a)
    #Warning message:
    #Grouping rowwise data frame strips rowwise nature
    

    This does not produce the warning:

    data.frame(a=1:4) %>% rowwise() %>% 
      ungroup() %>% 
      group_by(a)
    

提交回复
热议问题