Getting the minimum of the rows in a data frame

前端 未结 3 1020
一个人的身影
一个人的身影 2020-12-11 03:25

I am working with a dataframe that has 65 variables in it. The first variable catalogs a person, and the next 64 variables indicate the geographic distance that person is fr

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 04:20

    Or, using the example of Justin:

    df$shortest <- do.call(pmin,df[-1])
    

    see also ?pmin and ?do.call, and note that you can drop the first variable in your data frame by using the list indices (so not using any comma at all, see also ?Extract )

提交回复
热议问题