Reputation: 13
first, sorry for my english because I'm not englophone. And this leads to my problem, in my language, we use accent and other particular characters. I need to print a data.frame on a shiny datatable (renderDataTable), and some accents are not printed correctly. Exemple of lines bas printed, eg 10, 11, 12, 13, 14
Here is my code, which is inspired from the example of Rshiny web site, ref renderDataTable:
.libPaths("C:/R_library")
library(shiny)
niveau3 <- read.csv2("Libelle_NC.txt", encoding="UTF-8", header = FALSE, sep = ";", na.strings = "", stringsAsFactors = TRUE)
ui <- fluidPage(
fluidRow(
column(12,
dataTableOutput("table"),
)
)
)
server <- function(input, output) {
output$table <- renderDataTable(
{
niveau3
},
options = list(
pageLength = 15,
initComplete = I("function(settings, json) {alert('Done.');}")
)
)
output$tableAsiat <- renderDataTable({
asiat
})
}
shinyApp(ui= ui , server=server)
The file Libelle_NC.txt can be found on the first zip of the link towards data gouvernement of exportation/importation
The problem is that it seems there is non regularity of the displayed lines: for exemple line 9 of the rendered table print correctely "...(à..." but not for for line 10.
I look for options to be coded in options=list()
part of function renderDataTable
on the option reference link of jQuery DataTable page.
And I didn't find any option about encoding.
I was thinking that it was due to the read.csv
function which didnt' encode correctly, but a View(niveau3)
show a well printed data.frame.
Is there any manipulation or option that played on the encoding of a renderDataTable()
, or should I treat the data.frame before print process?
Thank you.
Upvotes: 1
Views: 1888
Reputation: 4072
Not sure if this would work, but you could try to reencode V2
using niveau3$V2 <- enc2native(niveau3$V2)
Taken from:
http://shiny.rstudio.com/articles/unicode.html
Upvotes: 1