R/add_ids.R

Defines functions add_ids

Documented in add_ids

#' Adds an id column to a given variable.
#'
#' @param df dataframe.  The data to add an id var to.
#' @param idname character. The name of the variable in the dataframe you want to be the id column.
#' @export
add_ids <- function(df, idname = 'id') {
  df <- cbind(seq(NROW(df)), df)
  names(df)[[1]] <- idname
  df
}
peterhurford/surveytools2 documentation built on Feb. 18, 2021, 9:13 p.m.