#' Full reshape of a data frame (to wide format)
#'
#' Takes in a dataframe and reshape it.
#'
#' @param DReshap DataFrame to reshape
#' @param idvar Variables by reshape
#'
#' @return Dataframe reshapped
#'
#' @examples
#' fnameData = "C:/Users/3rang/Documents/STAPS/M2/Mémoire/5 - R studio/WRK/DAT/MacokiV6.csv"
#' D = read.csv(fnameData)
#' idvar = c("ID", "Rep", "ReachNbCat", "PAR_NPAR", "App")
#' DReshap = FullReshap (D, idvar)
#'
#' @export
FullReshap <- function (DReshap, idvar) {
#a loop for each variable to reshape by
for (i in length(idvar):2){
Newidvar = idvar[1:i-1]
#reshape dataframe by current variable
DReshap <- reshape(
DReshap,
timevar = idvar[i],
idvar = Newidvar,
direction = "wide"
)
}
return (DReshap)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.