#' Oui/Non
#' Reorganise les variables non/oui vers oui/non.
#' @param df Data.frame
#'
#' @return un data.frame
#' @export
ouinonph <- function(df){
ldf <- length(df)
for (i in 1:ldf){
if(is.integer(df[,i])==F & is.numeric(df[,i])==F & length(levels(df[,i]))==2){
if (levels(df[,i])[1]=="non" & levels(df[,i])[2]=="oui"){
df[,i] <- as.factor(df[,i])
df[,i] <- factor(df[,i],c("oui","non"))
}
}}
return(df)
}
#' yes/no
#' Reorganise les variables no/yes vers yes/no.
#' @param df Data.frame
#'
#' @return un data.frame
#' @export
yesnoph <- function(df){
ldf <- length(df)
for (i in 1:ldf){
if(is.integer(df[,i])==F & is.numeric(df[,i])==F & length(levels(df[,i]))==2){
if (levels(df[,i])[1]=="no" & levels(df[,i])[2]=="yes"){
df[,i] <- as.factor(df[,i])
df[,i] <- factor(df[,i],c("yes","no"))
}
}}
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.