2017-11-14 1 views
1

i auf einer glänzende Anwendung arbeitete, wo mein Benutzeraktualisiert einen vorhandenen Datenrahmen mit Eingabewerten in R glänzend

  1. Eingang ein Integer-Wert
  2. Wert aus der Liste auswählen

wenn mein Benutzer klicken auf Aktionsschaltfläche, ein vorhandener Datenrahmen muss mit den eingegebenen Werten aktualisiert werden.

Der aktualisierte Datenrahmen sollte auf dem Armaturenbrett Körper

library(shiny) 
library(shinydashboard) 

ui <- 

dashboardPage(

    dashboardHeader(title = "title"), 
    dashboardSidebar(

     selectInput("transaction_type", "select transaction type:", choices = 
    tranlist,selected = NULL), 
    selectInput("entry_type", "select entry type", choices = entrylist), 
    selectInput("sic", "select sic", choices = siclist), 
    selectInput("markettype", "select market type", choices = marketlist), 
    numericInput("qty", "enter quantity","",min = 0), 
    numericInput("volume", "enter Total_amnt","",min = 0), 

    ), 
    dashboardBody(
     tableOutput("result") 
    ) 
) 

server <- function(input, output,session){ 

pos <- reactive({ 

if(input$goButton >0){ 


pos <- test[test$transaction_type == input$transaction_type && 
test$entry_type == input$entry_type && test$qty == input$qty && 
test$total_amount == input$volume && test$Average_Amnt == (input$volume/ 
input$qty) && test$markettype == input$markettype && test$sic == input$sic] 
} else{pos<- test} 

return(pos) 

}) 

output$result <- renderTable(pos()) 

} 

Während Sie auf die Aktionstaste angezeigt werden, erhalte ich die folgende Fehlermeldung.

Zuhören auf http://127.0.0.1:7447 Warnung: Fehler in < -: ungültiger Index Typ 'Liste' Stapel trace (innerste zuerst): 80: xtable.data.frame 79: 78: do.call 77: origRenderFunc 76: Ausgabe $ Ergebnis 1: runApp

Bitte helfen Sie mir. Danke im Voraus.

dput Ausgabe unter

> dput(test) 
structure(list(transaction_type = structure(4L, .Label = c("10", 
"11", "15", "20", "21", "25"), class = "factor"), entry_type = 
structure(13L, .Label = c("AMER", 
"ARC", "BOC", "CCD", "CIE", "CTX", "DISC", "EFT", "JCB", "MAST", 
"POP", "POS", "PPD", "RCK", "TEL", "VISA", "WEB"), class = "factor"), 
qty = 391L, total_amount = 10212.13, sic = structure(12L, .Label = c("4900", 
"5047", "6012", "6300", "6513", "7372", "7393", "7399", "7997", 
"8099", "8351", "8931", "8999", "9311", "9399"), class = "factor"), 
markettype = structure(1L, .Label = c("0", "1", "2", "3", 
"4"), class = "factor"), Average_Amnt = 26.1179795396419), .Names = 
c("transaction_type", 
"entry_type", "qty", "total_amount", "sic", "markettype", "Average_Amnt" 
), row.names = c(NA, -1L), spec = structure(list(cols = structure(list(
location_id = structure(list(), class = c("collector_integer", 
"collector")), settle_date = structure(list(format = ""), .Names = "format", 
class = c("collector_date", 
"collector")), transaction_type = structure(list(), class = 
c("collector_integer", 
"collector")), entry_type = structure(list(), class = 
c("collector_character", 
"collector")), response_code = structure(list(), class = 
c("collector_character", 
"collector")), funding_type = structure(list(), class = 
c("collector_character", 
"collector")), qty = structure(list(), class = c("collector_integer", 
"collector")), service_fee = structure(list(), class = c("collector_skip", 
"collector")), total_amount = structure(list(), class = 
c("collector_double", 
"collector")), organization_id = structure(list(), class = 
c("collector_skip", 
"collector")), status = structure(list(), class = c("collector_character", 
"collector")), sic = structure(list(), class = c("collector_integer", 
"collector")), markettype = structure(list(), class = c("collector_integer", 
"collector")), isoid = structure(list(), class = c("collector_skip", 
"collector")), city = structure(list(), class = c("collector_skip", 
"collector")), StateProvince = structure(list(), class = 
c("collector_character", 
"collector")), postalcode = structure(list(), class = c("collector_skip", 
"collector")), CreateDate = structure(list(format = ""), .Names = "format", 
class = c("collector_datetime", 
"collector")), DeleteDate = structure(list(), class = c("collector_skip", 
"collector"))), .Names = c("location_id", "settle_date", 
"transaction_type", "entry_type", "response_code", "funding_type", 
"qty", "service_fee", "total_amount", "organization_id", "status", 
"sic", "markettype", "isoid", "city", "StateProvince", "postalcode", 
"CreateDate", "DeleteDate")), default = structure(list(), class = 
c("collector_guess", 
"collector"))), .Names = c("cols", "default"), class = "col_spec"), class = 
c("tbl_df", 
"tbl", "data.frame")) 
+0

Könnten Sie einige reproduzierbare Beispieldaten für 'test' und' translist' mit 'dput()'? –

+0

dput (test) Struktur (Liste (transaction_type = Struktur (4L, .Label = c ("10", "11", "15", "20", "21", "25"), class = " Faktor "), Eintragstyp = Struktur (13L, .Label = c (" AMER ", " ARC "," BOC "," CCD "," CIE "," CTX "," DISC "," EFT "," JCB "," MAST ", " POP "," POS "," PPD "," RCK "," TEL "," VISA "," WEB "), Klasse =" Faktor "), , sic = Struktur (12L .Label = c ("4900", "5047", "6012", "6300", "6513", "7372", "7393", "7399", "7997", "8099", "8351 "," 8931 "," 8999 "," 9311 "," 9399 "), class =" faktor "), markttyp = struktur (1L, .Label = c (" 0 "," 1 "," 2 ", "3", "4"), class = "factor") – deadpool

+0

Bitte fügen Sie es zu Ihrer Frage als Edit –

Antwort

0

Der folgende Code für mich gearbeitet.

library(shiny) 
library(shinydashboard) 

ui = dashboardPage(

dashboardHeader(title = "title"), 
dashboardSidebar(

    selectInput("transaction_type", "select transaction type:", choices = 
       tranlist), 
    selectInput("entry_type", "select entry type", choices = entrylist), 
    selectInput("sic", "select sic", choices = siclist), 
    selectInput("markettype", "select market type", choices = marketlist), 
    numericInput("qty", "enter quantity","",min = 0), 
    numericInput("volume", "enter Total_amnt","",min = 0), 
    actionButton("goButton","Enter") 

), 
dashboardBody(
    tableOutput("result") 

) 
) 


#server.R 

function(input, output,session){ 


pos <- eventReactive(input$goButton,{ 

if(input$goButton >0){ 


test[1:7] = c(input$transaction_type, input$entry_type, input$qty, 
input$volume , input$sic, input$markettype, input$volume/input$qty) 
} else{pos <- test} 


test 

}) 

output$result <- renderTable(pos()) 

} 
Verwandte Themen