You can add a sequence of numbers very easily with
data$ID <- seq.int(nrow(data))
If you are already using library(tidyverse)
, you can use
data <- tibble::rowid_to_column(data, "ID")
More Related Contents:
- Count number of rows within each group
- Drop unused factor levels in a subsetted data frame
- Why is it not advisable to use attach() in R, and what should I use instead?
- Create an empty data.frame
- Create a group number for each consecutive sequence
- Subset data frame based on multiple conditions [duplicate]
- R – Concatenate two dataframes?
- Remove columns with zero values from a dataframe
- How to convert dataframe into time series?
- Merge unequal dataframes and replace missing rows with 0
- How to access the last value in a vector?
- Removing display of row names from data frame
- How to delete rows from a data.frame, based on an external list, using R?
- Add extra level to factors in dataframe
- Dataframe create new column based on other columns
- What is about the first column in R’s dataset mtcars?
- Last Observation Carried Forward In a data frame? [duplicate]
- Determine the data types of a data frame’s columns
- finding close match from data frame 1 in data fame 2
- Combine several data frames in the global environment by row (rbind)
- Changing Million/Billion abbreviations into actual numbers? ie. 5.12M -> 5,120,000 [duplicate]
- Extract text after “/” in a data frame column
- use multiple columns as variables with sapply
- Deleting specific rows from a data frame
- Reshape a dataframe to long format with multiple sets of measure columns [duplicate]
- Count number of non-NA values for every column in a dataframe [duplicate]
- Undefined columns selected when subsetting data frame
- Difference between `names(df[1])
- How to create a new variable in a data.frame based on a condition?
- Interpolating timeseries