r - 如何在 Googlesheet 中将许多闪亮的输入保存为 data.frame?
问题描述
我正在尝试构建一个应用程序,从 3 个输入生成一个 data.frame,在主面板中显示它,最后将最终的 data.frame 保存到 GoogleSheet 中。我使用此表作为基于 R 闪亮中的用户输入的输出来完成第一步,但是当我尝试保存它时,我收到了这个错误:
自动刷新过时的 OAuth 令牌。
√ 写信给 Axie。
√ 向 Principal 添加 2 行。
警告:错误:不知道如何从类 <integer/shinyActionButtonValue> 中创建实例。
[没有可用的堆栈跟踪]
这是我的代码:
library(shiny)
library(tidyverse)
library(googlesheets4)
library(DT)
# Authorize googlesheets4
gs4_auth(
cache = ".secrets",
email = "my email"
)
# GoogleSheets ------------------------------------------------------
Linksheet <- "linkGoogleSheet"
sheet <- "Principal"
UI = fluidPage(
headerPanel('Axie'),
sidebarPanel(
dateInput('date', "Choose today's date:", value = NULL, min = NULL, max = NULL,
format = "yyyy-mm-dd", startview = "month", weekstart = 0,
language = "en", width = NULL)
,numericInput("slp_rodada", label = h3("Submit SLP"), value = NA)
,numericInput("rank_rodada", label = h3("Submit Rank"), value = NA)
,actionButton("action", label = "Submit Scores") )
,mainPanel(
DTOutput("diary_table")
,actionButton("save", label = "Save data")
))
SERVER = function(input, output, session) {
tableValues <- reactiveValues(df = data.frame(Date = as.Date(as.character()),
Number_game = as.numeric(),
SLP = as.numeric(),
Rank = as.numeric(),
check.names = FALSE))
observeEvent(input$action, {
temp <- tableValues$m
newRow <- data.frame(Date = input$date,
Number_game = input$action,
SLP = input$slp_rodada,
Rank = input$rank_rodada)
if(!is.null(temp)) {
if(isolate(input$date) < temp[nrow(temp), 1]) {
temp <- rbind(temp, newRow)
temp <- dplyr::arrange(temp, Date)
} else {
temp <- rbind(temp, newRow)
}
} else {
temp <- rbind(temp, newRow)
}
tableValues$m <- temp
})
output$diary_table <- DT::renderDataTable({ tableValues$m })
observeEvent(input$save,{
# Linksheet %>% sheet_append(data = newRow ,sheet = sheet )
Linksheet %>% sheet_append(data = isolate(tableValues$m) ,sheet = sheet )
# reinitiating the page
tableValues <- reactiveValues(df = data.frame(Date = as.Date(as.character()),
Number_game = as.numeric(),
SLP = as.numeric(),
Rank = as.numeric(),
check.names = FALSE))
updateNumericInput(session, inputId = "slp_rodada", label = h3("Submit SLP"), value = NA)
updateNumericInput(session,"rank_rodada", label = h3("Submit Rank"), value = NA)
updateActionButton(session, "action", label = "Submit Scores")
})
}
shinyApp(
ui = UI,
server = SERVER
)
解决方案
推荐阅读
- kubernetes - Kubernetes 在不同网络中的设置
- .net - Vb.net在面板内的自定义文本上添加占位符
- vue.js - 在 vuetify 中添加 v-tooltip 到 v-treeview
- c++ - 与功能区页面交互时插入符号或网格光标消失
- php - codeigniter 3.1.9 xss_clean 在 % de 之后截断文本
- php - 选择包含特定关键字 PHP 的所有行
- c# - 将不断变化的 C# 对象序列化为 JSON
- database - 数据库连接 - 正确连接?
- c# - 如何将命令行参数传递给 csharp-shell
- ios - 如何显示在 tableview 之外并且可滚动的父视图?