Referencing Row Number in R

前端 未结 4 1395
温柔的废话
温柔的废话 2021-02-04 01:53

How do I reference the row number of an observation? For example, if you have a data.frame called \"data\" and want to create a variable data$rownumber

4条回答
  •  北海茫月
    2021-02-04 02:42

    Perhaps with dataframes one of the most easy and practical solution is:

    data = dplyr::mutate(data, rownum=row_number())

提交回复
热议问题