Я пытаюсь создать блестящее приложение, подобное тому, где после выбора входных данных я могу щелкнуть по «отправке» botton, который автоматически загружает cvs файл, добавляющий строку с новыми данными. я вижу, что структура должна быть похожа на обследование одного, это мой код, он дает следующее сообщение об ошибке:Сохраните введенное значение в файле cvs, добавив строку при каждом представлении, в блестящем
Listening on http://127.0.0.1:3716
Warning: Error in <-: invalid type/length (closure/0) in vector allocation
Stack trace (innermost first):
42: server [/Users/cleliagasparri/app2/app.R#47]
1: runApp
Error in Data[nrow(Data) + 1, ] <- reactive(if (input$Action == 1) { :
invalid type/length (closure/0) in vector allocation
Код:
library(shiny)
library(googlesheets)
library(DT)
# Define UI for application that draws a histogram
library(shiny)
ui <- fluidPage(
textInput("nome", "Nome"),
textInput("cognome", "Cognome"),
textInput("email", "Email"),
radioButtons("gioiello", label = "Gioiello", choices = c("Orecchini" = 1, "Collana" = 2)
),
conditionalPanel(condition = "input.gioiello == 1",
selectInput(inputId = "modello",
label = "Modello",
choices = c("Serpenti" = 1, "Foglie" = 2, "Edere" = 3, # Responses
"Neither Agree nor Disagree" = 4, "Agree Somewhat" = 5, "Agree" = 6,
"Agree Strongly" = 7)
)),
conditionalPanel(condition = "input.gioiello == 2",
selectInput(inputId = "modello", # What we are calling the object
label = "Modello", # Label
choices = c("Serpenti" = 1, "Foglie" = 2, "Edere" = 3, # Responses
"Neither Agree nor Disagree" = 4, "Agree Somewhat" = 5, "Agree" = 6,
"Agree Strongly" = 7)
)),
radioButtons("materiale", label = "Materiale", choices = c("Oro", "Argento", "Bronzo rosa", "Bronzo giallo", "Rame")
),
actionButton("Action", "Submit"), tags$hr()
)
library(shiny)
library("DT")
server <- function(input, output){
Results <- reactive(c(nome, cognome, email, gioiello, modello, materiale, Sys.Date()))
Data[nrow(Data) +1,] <- reactive( if(input$Action == 1) {Results()}) # Put data into next row of the "Data" when the action button is pressed
write.csv(Data, file = "/Users/cleliagasparri/app2/Data.csv") # Download new Data to replace Data.csv file in the shiny folder
##### Function 1, Create a data download option ####
output$downloadData <- downloadHandler( # Create the download file name
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(Data, file) # put Data() into the download file
})
}
shinyApp(ui = ui, server = server)
Не могли бы вы предоставить образцы данных? Также библиотека не должна находиться внутри '' ''. Он должен быть 'library (DT)' вместо 'library (" DT ")' – SBista
Спасибо! Я хочу использовать это приложение, чтобы вставлять данные о продаже драгоценностей, поэтому после того, как вы вставляете проданную часть, я нажимаю кнопку «отправить», которая добавляет строку с данными о продажах в файл csv. Строка должна быть заполнена таким образом: имя, фамилия, адрес электронной почты, тип драгоценности (серьга, ожерелье, браслет ..), модель (различная для каждого типа), материал (золото, серебро, бронза), цена, sysdate – Clelia