R/tidyProfession.R

Defines functions tidyProfession

#' profession factor levels
#'
#' @description This function recodes factor levels in profession vector
#' @param df The name of the dataframe you want to manipulate
#' @return datatframe, tibble
#' @keywords profession levels
#' @import dplyr, forcats
#' @export
#' @examples tidyProfession(df = df)

tidyProfession <- function(df) {

  df <- df %>%
    dplyr::mutate(antragsteller1beschaeftigungsart = forcats::fct_recode(antragsteller1beschaeftigungsart,
                                                         'SELBSTSTAENDIGER'  = 'GF_GESELLSCHAFTER',
                                                         'SELBSTSTAENDIGER'  = 'FREIBERUFLER',
                                                         'SELBSTSTAENDIGER'  = 'SELBSTAENDIGER'),
           antragsteller2beschaeftigungsart = forcats::fct_recode(antragsteller2beschaeftigungsart,
                                                         'SELBSTSTAENDIGER'  = 'GF_GESELLSCHAFTER',
                                                         'SELBSTSTAENDIGER'  = 'FREIBERUFLER',
                                                         'SELBSTSTAENDIGER'  = 'SELBSTAENDIGER'),
           antragsteller1beschaeftigungsart = forcats::fct_relevel(antragsteller1beschaeftigungsart,c("ANGESTELLTER","ARBEITER", "BEAMTER", "SELBSTSTAENDIGER", "HAUSFRAU", "RENTNER", "ARBEITSLOSER")),
           antragsteller2beschaeftigungsart = forcats::fct_relevel(antragsteller2beschaeftigungsart,c("ANGESTELLTER","ARBEITER", "BEAMTER", "SELBSTSTAENDIGER", "HAUSFRAU", "RENTNER", "ARBEITSLOSER"))
    )


  return(df)

}
europace-privatkredit/tidyPkuData documentation built on Oct. 2, 2019, 3 a.m.