Nothing
#' Flag group Listing
#'
#' Creates a vector containing the column numbers in a dataset from a list of variable flags. The variable list is provided in the form of a prefix (e.g. "statusinemployment") and a suffix (e.g. 1:10), and a flag indicator (e.g. "flag") building a variable list to be matched against the variable names in the dataset.
#' @author Beat Hulliger, Juan Berdugo
#' @param prefix (mandatory) A base variable name which is part of a variable group.
#' @param suffix (mandatory) Vector of the suffixes considered.
#' @param flagind (optional) An indicator to identify the flag variables (e.g. "flag").
#' @param data (mandatory) A dataframe containing the variables and observations to be analyzed.
#' @return Column numbers of variable group within the dataset.
#' @export
flaggroup <- function(prefix,suffix="", data, flagind="flag")
{
p <- length(suffix)
varn <- character(p)
for (j in 1:p)
{
varn[j] <- paste(prefix,suffix[j],flagind,sep="")
}
varnames<- names(data)
varnames<- tolower(varnames)
varj <- pmatch(tolower(varn),varnames)
if (length(varj)<length(suffix)) cat(paste("Warning: not all variables match the dataset.\n"))
return(varj)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.