- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是Shiny仪表板的初学者,我有一个困扰我很长时间的问题。
我的最终目标是将数据分配给名为“myData”的变量,但我为用户提供了从本地文件或在线文件(在我的例子中为 GoogleSheet)上传数据的选项。
下面是我的应用程序的简化版本。为了实现目标,我做了:
但是,问题是:
有 friend 或者专家可以帮我解决这个问题吗?我真的非常感谢您的帮助!
library(shiny)
library(shinydashboard)
library(googlesheets4)
library(googledrive)
server = function(session, input, output)
{
# "input_option" is used to select whether input data from local or online
input_option = reactive(
input$select_upload
)
# Upload the data
myData = eventReactive(
input$select_upload,
if(input$select_upload == "local")
{
req(input$file_myData)
read.csv(
input$file_myData$datapath,
header = T,
stringsAsFactors = F,
sep = input$sep_file_myData)
}
else if(input_option() == "online")
{
as.data.frame(gs4_find("myData_sample") %>% range_read())
}
)
# display the myData data uplaoded ---
output$display_myData = eventReactive(
myData(),
DT::renderDataTable(
myData(), options = list(scrollX = T)
)
)
}
ui = dashboardPage(
dashboardHeader(title = "My dashboard"),
dashboardSidebar(
sidebarMenu(
id = "sidebarmenu",
menuItem("Data upload", tabName = "data", icon = icon("database")),
conditionalPanel(
"input.sidebarmenu === 'data'",
selectInput(
inputId = "select_upload",
label = "please select an option",
choices = c("local", "online"),
selected = "local"
)
)
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "data",
conditionalPanel(
condition = "input.select_upload === 'local'",
fileInput(inputId = "file_myData",
label = "Choose csv file",
accept = c("text/csv", "text/comma-separated-values", "text/plain", ".csv")),
radioButtons(inputId = "sep_file_myData", "Separator",
choices = c(Comma = ",", Semicolon = ";", Tab = "\t"),
selected = ",")
),
fluidRow(
box(
title = "myData information uploaded", solidHeader = T, status = "primary",
width = 12,
DT::dataTableOutput(outputId = "display_myData")
)
)
)
)
)
)
shinyApp(ui, server)
最佳答案
服务器中的两项更改将使本地文件正常工作,也可能使 googledrive 正常工作。
server = function(session, input, output)
{
# "input_option" is used to select whether input data from local or online
input_option = reactive(
input$select_upload
)
# Upload the data
myData = eventReactive(
input$file_myData, # HERE!
if(input$select_upload == "local")
{
req(input$file_myData)
read.csv(
input$file_myData$datapath,
header = T,
stringsAsFactors = F,
sep = input$sep_file_myData)
}
else if(input_option() == "online")
{
as.data.frame(gs4_find("myData_sample") %>% range_read())
}
)
# display the myData data uplaoded --- # AND HERE!
output$display_myData = DT::renderDataTable(
myData(),
options = list(scrollX = T)
)
}
文章末尾有两个问题:
print()
语句的老式方法来调试 Shiny 的应用程序。当您在应用程序中执行操作时,观察 R 控制台以查看代码中的哪些位置被访问/未被访问。您还可以使用 str()
将仅在应用运行时存在的对象结构打印到屏幕上,以便您了解如何处理它们。关于R Shiny 仪表板: Upload data from both local file and the online database (such as Google Sheet),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63651796/
我已经能够在我的 Centos 7 服务器上成功设置 kubernetes。 在遵循 documentation 之后尝试使仪表板工作,运行“kubectl 代理”它 尝试使用 127.0.0.1:9
我正在尝试为用作仪表板的网络应用程序设计数据库架构。 可以有任意数量的仪表板(用户可以创建新的仪表板) 每个仪表板都与团队相关联(每个仪表板大约 10-25 个团队) 每个团队都有成员(每个团队约 1
我已经在 Windows VM 上部署了 minikube,并且 minikube VM 是在 Virtualbox 上使用仅主机 IP 创建的。 我已经使用 NodePort IP 部署了 Kube
我刚刚安装了 xampp-win32-5.5.30 并且在 xampp 控制面板中 Apache 和 mysql 都启动没有任何错误,但我发现: 1) 本地主机 在我的浏览器中重定向到另一个页面 本地
我是 ReactJS 的新手。我想在我的项目中使用 ReactJS-AdminLTE。谁能告诉我如何逐步使用它。 我遵循的步骤 1) 我使用 https://www.tutorialspoint.co
我们正在创建一个仪表板,用于显示给定系统在一段时间内(具体来说是过去 24 小时)内的异常数量。该图如下所示: 如果您仔细观察,最后一个柱形图是一天前的,而不是今天(请参阅图表中最后一个柱形图生成的时
我已经通过 Kubespray 成功部署了 Kubernetes,一切似乎都工作正常。我可以通过 kubectl 访问集群并列出节点、pod、服务、 secret 等。还可以应用新资源,仪表板端点可以
我在本地使用 KUBEADM 工具配置了具有 1 个主节点和 4 个工作节点的 kubernetes 集群。所有节点都运行良好。部署了一个应用程序并能够从浏览器访问该应用程序。我尝试了很多方法来使用
我们正在创建一个仪表板,用于显示给定系统在一段时间内(具体来说是过去 24 小时)内的异常数量。该图如下所示: 如果您仔细观察,最后一个柱形图是一天前的,而不是今天(请参阅图表中最后一个柱形图生成的时
我在 DashBoard Demo 看到了 PrimeFaces 仪表板演示。我目前有 PrimeFaces 1.1 jar。它可以工作还是我必须升级到下一个版本?我正在使用 JSF 1.2 和 Se
我不熟悉 Bootstrap 、HTML 以及与 Web 开发有关的所有内容。我正在使用 bootstrap 构建仪表板,我设法使基本布局正确。我的仪表板有一个顶部和侧面导航栏。 我现在想在不同页面之
这个问题在这里已经有了答案: Starting Shiny app after password input (6 个答案) 关闭 2 年前。 我正在制作一个 Shiny 的应用程序,它将显示一个仪
我正在尝试将 Grafana 仪表板的导入复制到 Grafana。 我正在使用下一个模块: - name: Export dashboard grafana_dashboard: graf
我按照本指南 link安装 kubernetes 集群,我没有错误,但我无法访问 kubernetes-Dashboard 我做了kubectl create -f https://rawgit.co
我们现在正在使用 Apache JMeter 3.1,并且对新功能 Dashboard 生成非常感兴趣。我们可以使用“-g”选项生成它并且它工作正常。 但我们也有兴趣自定义仪表板。例如: 从第一页删除
我是 wordpress 的新手,对某些东西有点困惑。我正在尝试为自己建立一个分类市场类型的网站。我不是为“客户” build 这个。由于我的编码技能达不到标准,我可能会使用几个不同的插件。最终,我希
是否可以有一个受限的 Kubernetes 仪表板?这个想法是让一个 pod 在集群中运行 kubectl proxy(受基本 HTTP 身份验证保护)以快速了解状态: pod 的日志输出 运行服务和
有人可以解释一下如何用 cocoa 读取(或至少下载为 XML 格式)吗?我就这样试过了。这可能是完全错误的:)。 NSMutableURLRequest* request = [[NSMutable
我想将我自己的部分添加到 umbraco 仪表板,以便我可以将我自己的管理部分集成到现有的登录/管理结构中。如果不编辑和重新编译 umbraco 源代码本身,这可能吗?是否推荐?如果是这样,是否有人有
我正在尝试使用配置文件访问 kubernetes 仪表板。从我选择配置文件时的身份验证中,它给出了‘ Not enough data to create auth info structure .’但
我是一名优秀的程序员,十分优秀!