ids2rownum takes a vector of ids and converts it to the right row number in the dataset; ids should be unique in the dataset that is, don't pass the function panel data with multiple same ids
ids2rownum(ids, data, idname)
vector of row numbers
vector of ids
data frame
unique id
ids <- seq(1, 1000, length.out = 100)
ids <- ids[order(runif(100))]
df <- data.frame(id = ids)
ids2rownum(df$id, df, "id")
Run the code above in your browser using DataLab