Spanish characters did not work properly in rmarkdown

Hi, I am developing an .Rmd document to produce a word document. However, I am using Spanish characters like ("í", "á", "ñ", etc). For example, what I want to produce is:

Elaboración análisis señalando

Nevertheless, as I mentioned, when I knit the document, the word document looks like:

Elaboración de análisis señalando

Here is the report in the session info.

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Peru.1252  LC_CTYPE=Spanish_Peru.1252    LC_MONETARY=Spanish_Peru.1252 LC_NUMERIC=C                 
[5] LC_TIME=Spanish_Peru.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.4.0    stringr_1.4.0    dplyr_0.8.2      purrr_0.3.2      readr_1.3.1      tidyr_0.8.3      tibble_2.1.3    
 [8] ggplot2_3.2.0    tidyverse_1.2.1  openxlsx_4.1.0.1

loaded via a namespace (and not attached):
 [1] zip_2.0.2        Rcpp_1.0.1       cellranger_1.1.0 pillar_1.4.2     compiler_3.4.3   tools_3.4.3      digest_0.6.19   
 [8] lubridate_1.7.4  jsonlite_1.6     evaluate_0.14    nlme_3.1-131     gtable_0.3.0     lattice_0.20-35  pkgconfig_2.0.2 
[15] rlang_0.4.0      cli_1.1.0        rstudioapi_0.10  yaml_2.2.0       haven_2.1.0      xfun_0.8         withr_2.1.2     
[22] xml2_1.2.0       httr_1.4.0       knitr_1.23       hms_0.4.2        generics_0.0.2   grid_3.4.3       tidyselect_0.2.5
[29] glue_1.3.1       R6_2.4.0         readxl_1.3.1     rmarkdown_1.13   modelr_0.1.4     magrittr_1.5     backports_1.1.4 
[36] scales_1.0.0     htmltools_0.3.6  rvest_0.3.4      assertthat_0.2.1 colorspace_1.4-1 stringi_1.4.3    lazyeval_0.2.2  
[43] munsell_0.5.0    broom_0.5.2      crayon_1.3.4    

BTW I just knitting the document with the keyboard shorcut and the code is save in "ISO8859-1"
Please, any comment will be very helpful.
Regards

1 Like

What version of RStudio are you using? Could you share a reproducible example? for example I'm using RStudio 1.2.1541 and this works for me (I also use LC_ALL=Spanish_Peru.1252)

---
title: "Archivo de Prueba"
output:
  word_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Esto funciona para mi
Elaboración análisis señalando

```{r pressure, echo=FALSE}
plot(pressure)
```

1 Like

Sure.

---
title: "Informe"
author: "Alí Meres"
date: "28/6/2019"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

D. Elaboración de análisis señalando

> RStudio.Version()
$citation
To cite RStudio in publications use:
  RStudio Team (2018). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL http://www.rstudio.com/.
A BibTeX entry for LaTeX users is
  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{RStudio Team}},
    organization = {RStudio, Inc.},
    address = {Boston, MA},
    year = {2018},
    url = {http://www.rstudio.com/},
  }
$mode
[1] "desktop"
$version
[1] ‘1.2.1335’

Regards
1 Like

I can't reproduce your issue, it works as expected for me, try updating to the preview version of RStudio and see if that helps. https://www.rstudio.com/products/rstudio/download/preview/

1 Like

Ok I will. Thanks for your help.
Just one more question, How can I change the font in the code?

1 Like

You can specify a reference word document and change font there (among other things).

output:
  word_document:
    reference_docx: word-styles-reference-01.docx
1 Like

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