original When I try to upload my csv file I recieve an error stating that "input string 7 is invalid in this locale". I have attempted to use encoding= "UTF-8" and encoding="UTF-16LE". I used UTF-16LE because I researched that this is the encoding used for csv files. However, I am still running into the error message. I am unsure how to check the encoding of the csv file.
Update: I am able to upload my file when I use fileEncoding = "UTF-8". However, the app is not recognizing the rows and columns.
library(shiny)
ui <- fluidPage(
navbarPage("Dashboard",
tabPanel(title = "Model",
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose .csv file", #add red asterisks to make this mandatory
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"),
),
),
mainPanel(
tabsetPanel(
tabPanel("Data",
tableOutput("tableOne"))
)
)
)
)
)
)
server <- function(input,output){
data <- reactive({
req(input$file1)
file1 <- input$file1
if(is.null(file1)){return()}
read.table(file=file1$datapath, fileEncoding = "UTF-8")
})
output$tableOne <- renderTable({
req(input$file1)
if(is.null(data())){return ()}
data()
})
#output$data <- renderTable(output$tableOne)
}
shinyApp(ui,server)