2016-04-04 7 views
0

私はRでRMDファイルを持っています。私はこのファイル内で光沢のあるアプリを使ってcsvファイルを読み込み、データをクリーニングしています。次に、Rmdファイル内のこのデータにアクセスする必要があります。クリーニングが完了した後でなければ、残りのRmdが処理されます。Shiny appとRmdファイルを組み合わせる

マイ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 
``` 

私は2つの問題を抱えている:

    私だけ 読み取り後とロードの始まりを、データをクリーニングしないで統計セクションに関連するコードを実行したい
  1. Rmd ファイル。
  2. 統計セクションのdtにアクセスできないのですが、どうすれば にアクセスできますか?

あなたの助け

答えて

0

ためのおかげで、私はthis questionで説明されているメソッドを使用して問題を解決しました。同じ問題を抱えている人に役立つことを願っています。

関連する問題