R 使用Shiny从Google Sheet中的用户收集数据
我想使用一个闪亮的界面从用户输入中收集数据,例如 这篇文章是为googlesheets软件包编写的,但我们现在需要使用googlesheets4 我认为我的代码将无法工作,因为我可能无法理解反应元素R 使用Shiny从Google Sheet中的用户收集数据,r,google-sheets,shiny,googlesheets4,R,Google Sheets,Shiny,Googlesheets4,我想使用一个闪亮的界面从用户输入中收集数据,例如 这篇文章是为googlesheets软件包编写的,但我们现在需要使用googlesheets4 我认为我的代码将无法工作,因为我可能无法理解反应元素 #load libraries library(shiny) library(shinydashboard) library(googlesheets4) library(DT) ui <- fluidPage( # Define UI ui <- fluidPage
#load libraries
library(shiny)
library(shinydashboard)
library(googlesheets4)
library(DT)
ui <- fluidPage(
# Define UI
ui <- fluidPage(
# App title ----
titlePanel("Seflie Feedback"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar to demonstrate various slider options ----
sidebarPanel(
# Input: Overall Rating
sliderInput(inputId = "helpful",
label = "I think this app is helpful",
min = 1,
max = 7,
value = 3),
actionButton("submit", "Submit")
),
mainPanel(
))
)
)
server <- function(input, output, session) {
# Reactive expression to create data frame of all input values ----
sliderValues <- reactive({
usefulRating <- input$helpful
Data <- data.frame(
Value = as.character(usefulRating),
stringsAsFactors = FALSE)
})
#This will add the new row at the bottom of the dataset in Google Sheets.
observeEvent(input$submit, {
MySheet <- gs4_find() #Obtain the id for the target Sheet
MySheet <- gs4_get('https://docs.google.com/spreadsheets/d/162KTHgd3GngqjTm7Ya9AYz4_r3cyntDc7AtfhPCNHVE/edit?usp=sharing')
sheet_append(MySheet , data = Data)
})
}
shinyApp(ui = ui, server = server)
#加载库
图书馆(闪亮)
图书馆(shinydashboard)
图书馆(谷歌地图4)
图书馆(DT)
ui#加载库
图书馆(闪亮)
图书馆(shinydashboard)
图书馆(谷歌地图4)
图书馆(DT)
用户界面
#load libraries
library(shiny)
library(shinydashboard)
library(googlesheets4)
library(DT)
ui <- fluidPage(
titlePanel("Seflie Feedback"),
sidebarLayout(
sidebarPanel(
#This is where a user could type feedback
textInput("feedback", "Plesae submit your feedback"),
),
#This for a user to submit the feeback they have typed
actionButton("submit", "Submit")),
mainPanel())
server <- function(input, output, session) {
textB <- reactive({
as.data.frame(input$feedback)
})
observeEvent(input$submit, {
Selfie <- gs4_get('https://docs.google.com/spreadsheets/d/162KTHgd3GngqjTm7Ya9AYz4_r3cyntDc7AtfhPCNHVE/edit?usp=sharing')
sheet_append(Selfie, data = textB())
})
}
shinyApp(ui = ui, server = server)