2016-06-06 37 views
0

我正在使用這個驚人的包,以便能夠使用我的閃亮應用讀取和上載數據。它工作正常,但是當我向工作表添加一行時,它不會保留來自服務器的相同編碼,它們的行爲不像以前行中的數據。我手動輸入的西班牙語名稱是可以的,但是當我使用該應用程序加載數據時,會在工作表中替換特殊的拉丁字符(UTF-8)。 該數據在後續會話中未被應用程序識別。將包含編碼的行添加到Google表單R包中googlesheets

library(googlesheets) 

table <- "Reportes" 

saveData <- function(data) { 
    # Grab the Google Sheet 
    sheet <- gs_title(table) 
    # Add the data as a new row 
    gs_add_row(sheet, input = data) 
} 

loadData <- function() { 
    # Grab the Google Sheet 
    sheet <- gs_title(table) 
    # Read the data 
    gs_read_csv(sheet) 
} 

然後,我在UI使用一個按鈕,並在服務器觀察員加載數據...

observeEvent(input$enviar, { 
    exit <- input$enviar 
    if (exit==1){ 

     addData <- c(as.character(input$fecha), 
        as.character(input$local), 
        as.character(input$dpto), 
        as.character(input$estado), 
        as.character(input$fsiembra), 
        as.character(input$ref), 
        as.character(loc$lat[loc$Departamento==input$dpto & loc$Localidad==input$local]), 
        as.character(loc$long[loc$Departamento==input$dpto & loc$Localidad==input$local]), 
        as.character(getZafra(input$fecha))) 

     saveData(addData) 

     d <- loadData() 

     reset('fecha') 
     reset('dpto') 
     reset('local') 
     reset('estado') 
     reset('fsiembra') 
     reset('ref') 
     reset('pass') 

     disable('enviar') 

    } 

}) 

請......如果有人能幫助我會非常快樂。

回答

0

我發現我需要uploding之前的字符編碼向量...

我用:

Encoding(addData) = "latin1" 
saveData(addData) 

和工作就好了!

相關問題