Create an ID (row number) column

后端 未结 8 2091
我在风中等你
我在风中等你 2020-11-29 02:06

I need to create a column with unique ID, basically add the row number as an own column. My current data frame looks like this:

   V1  V2
1  23  45
2  45  4         


        
8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 02:26

    Hope this will help. Shortest and best way to create ID column is:

    dataframe$ID <- seq.int(nrow(dataframe))
    

提交回复
热议问题