I have a RMD file in R and I use shiny app within this file to read csv file and do some cleaning on the data. Then I need to have access to this data in the Rmd file and only after finishing the cleaning, the remaining of Rmd is processed!
My Rmd:
---
title: "Report_HTML"
author: "Mohammad"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output: html_document
runtime: shiny
---
## Read file
This report...... (some text)
```{r, echo=FALSE}
library(tcltk)
inputPanel(
checkboxInput('header', 'Header', FALSE),
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
';'),
radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"'),
fileInput('file1', 'Choose a file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
)
)
remove.duplicates <- function(dt){
#some data cleaning
return(dt)
}
datasetInput <- reactive({
inFile <- input$file1
dt <- read.csv(inFile$datapath, header = input$header, sep = input$sep, quote = input$quote)
#Remove duplicates
dt2 <- remove.duplicates(dt)
dt2
})
renderDataTable({
datasetInput()
})
```
## Statistics
in this section I need to add some simple statistics like min, max, mean for each column of the `dt`.
```{r, echo=FALSE}
code for calculating min, max, and mean each column dt and show them in a table
```
I have two problems:
dt
in the Statistics section, how
can I have access?Thanks for your help