Hello, this is my first question!
Initially I had created a .rmd document with R, on a windows 10 home 64 bit system, by default the encoding is ANSI (Spanish_Spain.1252), after converting the file to another with UTF-8 encoding I use it with RStudio to generate with knitr a .pdf document
I have to use RStudio to generate the output because when I try to render from R with rmarkdown :: render () it finds when processing the code dataframes created from R with non-utf-8 encoding.
I'm adjusting the code to improve the output, and I find every time I run a set of lines with this error, repeating multiple times (for this code 4 times):
la condici�n tiene longitud > 1 y s�lo el primer elemento ser� usado
When executing the following lines in R, the behavior is as expected, it shows the html output of the table in the default browser. Also I can run knitr / knitr to PDF for all code without errors. I know this is unexpected behavior but it is my problem.
municipio <- "Murcia"
ejercicio <- "2019" #
columnas <- c("Municipio","Año","Esfuerzo Social","Población","Esfuerzo Social por Habitante","Ranking Esfuerzo Social por Habitante","Esfuerzo Total","Relevancia Esfuerzo Social","Ranking Relevancia Esfuerzo Social")
#formato.tabla <- c("striped", "hover", "condensed", "responsive")
formato.tabla <- c("hover", "condensed", "responsive")
df <- subset(esfuerzolocalsocialcapitales[order(-esfuerzolocalsocialcapitales$'Esfuerzo Social por Habitante'),], Año==ejercicio, columnas)
names(df)[names(df)=="Esfuerzo Social por Habitante"] <- 'EsSoHa'
names(df)[names(df)=="Ranking Esfuerzo Social por Habitante"] <- 'Ranking EsSoHa'
names(df)[names(df)=="Relevancia Esfuerzo Social"] <- 'ReEsSo'
names(df)[names(df)=="Ranking Relevancia Esfuerzo Social"] <- 'Ranking ReEsSo'
df %>%
mutate ('EsSoHa' = currency(`EsSoHa`, "€", digits=2, format="f", big.mark = ".", decimal.mark = ",")) %>%
mutate ('ReEsSo' = percent(`ReEsSo`, format="f", digits=2)) %>%
kable(caption=paste("Esfuerzo Social por Habitante ", ejercicio, " ", ".", "Capitales de provincia." , sep=" "),
row.names=F, digits = 2,
format.args = list(big.mark = ".", decimal.mark = ",")) %>%
kable_styling(bootstrap_options = formato.tabla,
html_font="\"Trebuchet MS\", verdana, sans-serif",
full_width = F, fixed_thead = T) %>%
# kable_classic(lightable_options = c("striped", "hover"),
# html_font="\"Trebuchet MS\", verdana, sans-serif",
# full_width = F, fixed_thead = T) %>%
row_spec(0, bold=T, monospace=F, color="white", background="#7B7B7B") %>%
row_spec(grep(paste("^",municipio,"$",sep=""),df$Municipio), bold=T, color="white", background="#C31A00") %>%
column_spec(grep("^EsSoHa$",colnames(df)), bold=T) %>%
footnote(general="Elaboración propia con datos del Ministerio de Hacienda.", general_title = "Nota: ") %>%
footnote(number=c("EsSoHa : Esfuerzo Social por Habitante : Esfuerzo Social / Habitantes",
"Ranking EsSoHa : Clasificación de los municipios según el Esfuerzo Social por Habitante",
"ReEsSo : Relevancia Esfuerzo Social : Esfuerzo Social / Esfuerzo Total",
"Ranking ReEsSo : Clasificación de los municipios según la Relevancia Esfuerzo Social"))