shiny - 在 rMarkdown 中上传文件并调用文件生成统计摘要
问题描述
我是新手,正在尝试学习 R,我制作了一个应用程序,您可以在其中上传 file.csv,但我不知道如何调用数据以生成摘要、绘图等。我将感谢您帮助理解如何进行的系统方法。代码附在下面。提前致谢。代码如下:
---
title: "Data Visualization"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
#storyboard: true
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(shinyWidgets)
library(DT)
library(formattable)
library(Hmisc)
library(tidyverse)
library(plotly)
library(ggplot2)
```
Sidebar {.sidebar}
=====================================================
```{r}
fileInput('file1', 'Choose a file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv')
)
```
Page 1
=========================================================
Column {data-width=350}
------------------------------------------------------------
### Dataset
```{r}
rv <- reactiveValues(data = NULL)
observe( {
req(input$file1)
inFile <- input$file1
data2 <- read.csv(inFile$datapath, stringsAsFactors=FALSE)
save(data2, file = "dataread.RData")
rv$data <- data2
})
DT::renderDataTable({
req(rv$data)
rv$data
})
```
------------------------------------------------------------
### Data Summary
```{r}
summary(???)
#how to call the data, if PLOT, is it:
#plot(inFile$file) # In the code chunk it also called:
#data2 <- read.csv(inFile$datapath, #stringsAsFactors=FALSE)
#if I write plot(data2), it doesn't generate a plot, neither for summary.
```
解决方案
推荐阅读
- node.js - 从 MongoDB 或文件(内存)中获取数据
- node.js - 垃圾收集时 NodeJS ref-struct 中的损坏内容
- javascript - 如何使用 imacros 浏览器提取 javascript 变量值?
- javascript - 我需要帮助从我的 MVC 控制器调用方法并使用 ajax 返回其返回值(int)
- reactjs - mount() 失败,因为目标容器不是 dom 元素
- python-2.7 - 为什么即使在关闭会话后,Python-Requests 在循环中发出 POST 时也会返回相同的数据?
- android - 根据按钮大小的变化改变文本大小
- mysql - 如何使用 Google Compute Engine 保持持久的 SQL 代理 Unix 套接字
- sql-server - 外键引用不匹配数据类型错误
- c# - 动态添加行到表格布局面板