Error Bookdown special characters

Hello, I'm trying to create a Bookdown and R send me an error:

When I create a Rmarkdown, there are not problems, but with Bookdown, I don't know how solve the problem. Te code with the problem is here; the problem is the variable "Año"

SEG_df2 <- SEG_df %>% 
  dplyr::select(
    Cod_EA,
    Año,
    Matriz,
    Cod_ETFA,   
    Cod_participante,
    Parametro,
    Metodo,
    VE, 
    u_VE, 
    U_VE_2, 
    sd_EA, 
    Resultado, 
    U_res, 
    ZScore, 
    Eval_Z,
    Puntaje, 
    Nota, 
    En,
    Muestra, 
    )

I appreciate your help.

Usually, this type of error can be fixed in RStudio by File | Reopen with Encoding and choosing UTF-8.

Yes, but the encoding of the file is UTF-8 and the character not have problem, the problem is when I build the Bookdown.

Try creating a new bookdown project and edit 01-Intro.Rmd to add the following text to the end. It should like like

Can you try create a reproducible example for me ?

One I could rerun on my side to see why there would be a difference between bookdown and rmarkdown.

Also, it seems you special character is for column names, I would suggest to use only ASCII characters in column names. That makes it less prone to error with all the tools handling data.

2 Likes

Thank you, I hope this reprex will suffice (the tibble is a head of SEG_df):

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tidyverse)

tibble::tribble(
  ~Año,        ~Cod_EA,            ~Matriz,   ~PIE, ~Cod_ETFA, ~Cod_participante,            ~Parametro, ~LCM,            ~Metodo, ~Reportar, ~Metodo_valido, ~Informa_res, ~Otro, ~Unidad,  ~VE, ~VE_2, ~VE_3, ~VE_4, ~u_VE, ~u_VE_2, ~u_VE_3, ~u_VE_4, ~U_VE, ~U_VE_2, ~U_VE_3, ~U_VE_4,            ~sd_EA, ~sd_EA_2, ~sd_EA_3, ~sd_EA_4, ~Resultado,   ~U, ~Resultado_2, ~U_2, ~Resultado_3, ~U_3, ~Resultado_4, ~U_4, ~ZScore, ~Zscore_2, ~Zscore_3, ~Zscore_4, ~Puntaje_1, ~Puntaje_2, ~Puntaje_3, ~Puntaje_4, ~Nota, ~En, ~En_2, ~En_3, ~En_4, ~Eval_Z, ~Eval_Z_2, ~Eval_Z_3, ~Eval_Z_4, ~Eval_Nota, ~Eval_En, ~Eval_En_2, ~Eval_En_3, ~Eval_En_4, ~Eval_Final, ~...1, ~cod_met, ~Resultado_c, ~absZ, ~Eval_LCM, ~Satisfactorio, ~ZScore_reporte, ~Muestra, ~value, ~U_res, ~Puntaje,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L", 1.51,    NA,    NA,    NA,  0.05,      NA,      NA,      NA,   0.1,      NA,      NA,      NA, 0.227023550978767,       NA,       NA,       NA,       1.58, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,     0.3,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA, 0.6,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m1",     NA,   0.06,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m2",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m3",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m4",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "016-01",            "3796", "Aluminio total (Al)",   NA,                 NA,         1,             NA,            0,    NA,  "mg/L", 1.51,    NA,    NA,    NA,  0.05,      NA,      NA,      NA,   0.1,      NA,      NA,      NA, 0.227023550978767,       NA,       NA,       NA,         NA,   NA,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "I",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m1",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "016-01",            "3796", "Aluminio total (Al)",   NA,                 NA,         1,             NA,            0,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA,   NA,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "I",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m2",     NA,     NA,       NA
)
#> # A tibble: 6 x 72
#>     Año Cod_EA  Matriz  PIE   Cod_ETFA Cod_participante Parametro    LCM Metodo 
#>   <dbl> <chr>   <chr>   <chr> <chr>    <chr>            <chr>      <dbl> <chr>  
#> 1  2020 EA-SMA~ Aguas ~ SYKE  010-01   2517             Aluminio ~  0.09 NCh231~
#> 2  2020 EA-SMA~ Aguas ~ SYKE  010-01   2517             Aluminio ~  0.09 NCh231~
#> 3  2020 EA-SMA~ Aguas ~ SYKE  010-01   2517             Aluminio ~  0.09 NCh231~
#> 4  2020 EA-SMA~ Aguas ~ SYKE  010-01   2517             Aluminio ~  0.09 NCh231~
#> 5  2020 EA-SMA~ Aguas ~ SYKE  016-01   3796             Aluminio ~ NA    <NA>   
#> 6  2020 EA-SMA~ Aguas ~ SYKE  016-01   3796             Aluminio ~ NA    <NA>   
#> # ... with 63 more variables: Reportar <dbl>, Metodo_valido <dbl>,
#> #   Informa_res <dbl>, Otro <lgl>, Unidad <chr>, VE <dbl>, VE_2 <lgl>,
#> #   VE_3 <lgl>, VE_4 <lgl>, u_VE <dbl>, u_VE_2 <lgl>, u_VE_3 <lgl>,
#> #   u_VE_4 <lgl>, U_VE <dbl>, U_VE_2 <lgl>, U_VE_3 <lgl>, U_VE_4 <lgl>,
#> #   sd_EA <dbl>, sd_EA_2 <lgl>, sd_EA_3 <lgl>, sd_EA_4 <lgl>, Resultado <dbl>,
#> #   U <dbl>, Resultado_2 <lgl>, U_2 <lgl>, Resultado_3 <lgl>, U_3 <lgl>,
#> #   Resultado_4 <lgl>, U_4 <lgl>, ZScore <dbl>, Zscore_2 <lgl>, ...
SEG_df2 <- SEG_df %>% 
  dplyr::select(
    Cod_EA,
    Año,
    Matriz,
    PIE,
    Cod_ETFA,
    Cod_participante,
    Parametro,
    Metodo,
    VE, 
    u_VE, 
    U_VE_2, 
    sd_EA, 
    Resultado, 
    U_res, 
    ZScore, 
    Eval_Z,
    Puntaje, 
    Nota, 
    En, 
    Muestra, 
    Eval_Final
  )
#> Error in dplyr::select(., Cod_EA, Año, Matriz, PIE, Cod_ETFA, Cod_participante, : objeto 'SEG_df' no encontrado

Created on 2021-12-21 by the reprex package (v2.0.1)

Is this the example ?

library(tidyverse)

SEG_df <- tibble::tribble(
  ~Año,        ~Cod_EA,            ~Matriz,   ~PIE, ~Cod_ETFA, ~Cod_participante,            ~Parametro, ~LCM,            ~Metodo, ~Reportar, ~Metodo_valido, ~Informa_res, ~Otro, ~Unidad,  ~VE, ~VE_2, ~VE_3, ~VE_4, ~u_VE, ~u_VE_2, ~u_VE_3, ~u_VE_4, ~U_VE, ~U_VE_2, ~U_VE_3, ~U_VE_4,            ~sd_EA, ~sd_EA_2, ~sd_EA_3, ~sd_EA_4, ~Resultado,   ~U, ~Resultado_2, ~U_2, ~Resultado_3, ~U_3, ~Resultado_4, ~U_4, ~ZScore, ~Zscore_2, ~Zscore_3, ~Zscore_4, ~Puntaje_1, ~Puntaje_2, ~Puntaje_3, ~Puntaje_4, ~Nota, ~En, ~En_2, ~En_3, ~En_4, ~Eval_Z, ~Eval_Z_2, ~Eval_Z_3, ~Eval_Z_4, ~Eval_Nota, ~Eval_En, ~Eval_En_2, ~Eval_En_3, ~Eval_En_4, ~Eval_Final, ~...1, ~cod_met, ~Resultado_c, ~absZ, ~Eval_LCM, ~Satisfactorio, ~ZScore_reporte, ~Muestra, ~value, ~U_res, ~Puntaje,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L", 1.51,    NA,    NA,    NA,  0.05,      NA,      NA,      NA,   0.1,      NA,      NA,      NA, 0.227023550978767,       NA,       NA,       NA,       1.58, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,     0.3,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA, 0.6,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m1",     NA,   0.06,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m2",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m3",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "010-01",            "2517", "Aluminio total (Al)", 0.09, "NCh2313/25.Of97.",         1,              1,            1,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA, 0.06,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "S",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m4",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "016-01",            "3796", "Aluminio total (Al)",   NA,                 NA,         1,             NA,            0,    NA,  "mg/L", 1.51,    NA,    NA,    NA,  0.05,      NA,      NA,      NA,   0.1,      NA,      NA,      NA, 0.227023550978767,       NA,       NA,       NA,         NA,   NA,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "I",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m1",     NA,     NA,       NA,
  2020, "EA-SMA-02-20", "Aguas Residuales", "SYKE",  "016-01",            "3796", "Aluminio total (Al)",   NA,                 NA,         1,             NA,            0,    NA,  "mg/L",   NA,    NA,    NA,    NA,    NA,      NA,      NA,      NA,    NA,      NA,      NA,      NA,                NA,       NA,       NA,       NA,         NA,   NA,           NA,   NA,           NA,   NA,           NA,   NA,      NA,        NA,        NA,        NA,         NA,         NA,         NA,         NA,    NA,  NA,    NA,    NA,    NA,      NA,        NA,        NA,        NA,         NA,       NA,         NA,         NA,         NA,         "I",    NA,       NA,           NA,    NA,        NA,             NA,              NA,     "m2",     NA,     NA,       NA
)
SEG_df2 <- SEG_df %>% 
  dplyr::select(
    Cod_EA,
    Año,
    Matriz,
    PIE,
    Cod_ETFA,
    Cod_participante,
    Parametro,
    Metodo,
    VE, 
    u_VE, 
    U_VE_2, 
    sd_EA, 
    Resultado, 
    U_res, 
    ZScore, 
    Eval_Z,
    Puntaje, 
    Nota, 
    En, 
    Muestra, 
    Eval_Final
  )

Can you share step on what to do with this table to recreate the issue ?

Thank you

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.