Uploading a file in rMarkdown and call the object to generate Statistics Summary

I am new and trying to learn R, I have made an app where you can upload your file.csv, but I can not figure out how to call the data in order to generate summary, plot etc. I will appreciate your help to understand the systematic approach in how to proceed. The code is attached below. Thanks in advance. The codes as follows:

title: "Data Visualization"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
#storyboard: true
runtime: shiny


library(flexdashboard)
library(shiny)
library(shinyWidgets)
library(DT)
library(formattable)
library(Hmisc)
library(tidyverse)
library(plotly)
library(ggplot2)

Sidebar {.sidebar}

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

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
})
# My question:
# What is the object in the fileinput: 
# Is it:  summary (data2), I have tried this but did not work

You can learn more about uploading files at https://mastering-shiny.org/action-transfer.html#upload

1 Like

Thanks Hadley. It helped.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.