R/change_group.R

Defines functions change_group

Documented in change_group

#' Change Group ID
#'
#' @description Change the group ID to be consequetive numbers, starting at 1, which is
#'              required for model fitting.
#'
#' @param group Numeric Vector. The grouping variable (e.g., subjects).
#'
#' @return Updated group ID.
#'
#' @examples
#' # congruent trials
#' dat <- subset(flanker,  id %in% c(39, 23, 2))
#' change_group(dat$id)
#' @export
change_group <- function(group){
   x <- rle(group)$lengths
   new_id <- rep(x = seq_along(x),
                times = x)
 return(new_id)
}

Try the vICC package in your browser

Any scripts or data that you put into this service are public.

vICC documentation built on Dec. 8, 2020, 5:07 p.m.