Skip to contents

The function creates a data.frame that contains data and changes type data. The data is assumed to have been previously loaded using the function "load_raw_data" from a .txt file associated with an entomology study conducted on the platform "Vigilancia Entomológica y Control Integral del Vector". This function aims to generate new data.frame suitable for further analysis and manipulation. It also saves the data from the data.frame to a .csv file

Usage

clean_raw_data(
  df,
  path_out = "data-raw/qr.csv",
  col_name = cols(Tipo_de_Estudio = col_factor(levels = c("Encuesta", "Verificacion")),
    Clave_Jurisdiccion = col_factor(levels = as.character(c(2601, 2602, 2603, 2604, 2605,
    2606))), Jurisdiccion = col_factor(levels = c("Hermosillo", "Caborca", "Cananea",
    "Cajeme", "Navojoa", "San_Luis_Río_Colorado")), Clave_Municipio = col_factor(levels
    = as.character(1:72)), Municipio = col_factor(), Clave_Localidad = col_factor(),
    Localidad = col_factor(), Sector = col_factor(levels = as.character(1:2000)),
    Fecha_de_Inicio = col_date(format = "%d/%m/%Y"), 
     Semana_Epidemiologica =
    col_factor(levels = as.character(1:53)), Casas_Revisadas = col_double(),
    Casas_Positivas = col_double(), Total_de_Recipientes_con_Agua = col_double(),
    Total_de_Recipientes_Positivos = col_double())
)

Arguments

df

a data.frame with raw data processed by the function "load_raw_data".

path_out

a string with path for that cleaned data to save.

col_name

selected variable names, as deemed necessary to analyze, previously selected with the function "load_raw_data".

Value

Data.frame and .csv file with cleaned data and correct format in variables selected to function "load_raw_data".

Examples


path_of_example = c(system.file("extdata",
                                "qr.csv",
                                package = "rStegomyia"
                                )
                   )


df_clean <- clean_raw_data(dfsm,
              path_out = path_of_example
              )
#> Warning: The following named parsers don't match the column names: Clave_Municipio, Municipio

head(df_clean)
#>   Tipo_de_Estudio Clave_Jurisdiccion Jurisdiccion Clave_Localidad  Localidad
#> 1    Verificacion               2601   Hermosillo            0001 HERMOSILLO
#> 2        Encuesta               2601   Hermosillo            0001 HERMOSILLO
#> 3        Encuesta               2601   Hermosillo            0001 HERMOSILLO
#> 4    Verificacion               2601   Hermosillo            0001 HERMOSILLO
#> 5        Encuesta               2601   Hermosillo            0001 HERMOSILLO
#> 6        Encuesta               2601   Hermosillo            0001 HERMOSILLO
#>   Sector Fecha_de_Inicio Semana_Epidemiologica Casas_Revisadas Casas_Positivas
#> 1    569      2021-01-07                     1             123               0
#> 2    569      2021-01-04                     1             123              24
#> 3    401      2021-01-07                     1              69               6
#> 4    401      2021-01-07                     1              66               3
#> 5    400      2021-01-07                     1             126               9
#> 6    403      2021-01-07                     1             153               9
#>   Total_de_Recipientes_con_Agua Total_de_Recipientes_Positivos
#> 1                           375                              0
#> 2                          1176                             45
#> 3                           141                              6
#> 4                           156                              3
#> 5                           399                              9
#> 6                           414                              9