0

I need to export a character string column to independent .docx documents (one doc per row). I was able to do it with the officer package, but the doc it generates automatically sets the language to english. I need it in spanish, but I hadn't been able to do it.

I tried to do it with Sys.setlocale("LC_ALL","es_ES.UTF-8"). Also reviewed the package information, but couldn't useful argument in any of the functions.

data <- data.frame(text = as.character("Lorem ipsum dolor sit amet,",
                                       "consectetur adipiscing elit,",
                                       "sed do eiusmod tempor incididunt",
                                       "ut labore et dolore magna aliqua."),
                   text_id = c(1, 2, 3, 4))

for (i in 1:nrow(data)){
  read_docx() %>%
    cursor_begin() %>%
    body_remove() %>%
    body_add_par(data$text[i], style = "Normal") %>%
    print(target = paste0(data$text_id[i], ".docx"))
}

Id need for all the docs to be automatically in spanish, but they all come in english. OSX language is set to spanish, as well as Word's default language. Also RStudio's main dictionary was set to spanish and all R's locales to es_ES.UTF-8.

0 Answers0