-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tyler Rinker
committed
Sep 27, 2018
1 parent
4db2230
commit 85b152c
Showing
6 changed files
with
144 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
title: 'Extract Text' | ||
output: | ||
flexdashboard::flex_dashboard | ||
runtime: shiny | ||
--- | ||
|
||
|
||
<style type="text/css"> | ||
|
||
.chart-title { /* chart_title */ | ||
font-size: 150%; | ||
|
||
</style> | ||
|
||
|
||
```{r} | ||
# rmarkdown::render( | ||
# system.file("extract_text_app/app/extract_text.Rmd", package = "textreadr") | ||
# ) | ||
|
||
library(readr) | ||
library(shinyWidgets) | ||
library(readr) | ||
library(readxl) | ||
library(shiny) | ||
library(shinyjs) | ||
library(magrittr) | ||
library(dplyr) | ||
library(textreadr) | ||
```` | ||
|
||
|
||
|
||
|
||
|
||
Inputs {.sidebar data-width=250} | ||
------------------------------------- | ||
|
||
|
||
```{r} | ||
fileInput('file_input', tags$b('Text File'), accept = c('.doc', '.docx', '.pdf', '.rtf', '.html')) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
```{r} | ||
mydata <- reactive({ | ||
|
||
req(input$file_input) | ||
in_file <- input$file_input | ||
dplyr::data_frame(text = textreadr::read_document(in_file$datapath)) | ||
|
||
}) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
```{r} | ||
output$downloadData <- downloadHandler( | ||
filename = function() { | ||
sprintf('text_file_%s.csv', gsub('\\s+', '_', gsub(':', '.', Sys.time()))) | ||
}, | ||
content = function(con) { | ||
|
||
dat <- mydata() | ||
|
||
|
||
readr::write_csv(dat, path= con) | ||
} | ||
) | ||
|
||
tags$div( | ||
uiOutput('next_instructions'), | ||
tags$br(), | ||
uiOutput('download_ui') | ||
) | ||
|
||
output$download_ui <- renderUI({ | ||
|
||
req(mydata()) | ||
tags$div( | ||
HTML('<span style = "color:black;padding-top: 125px;"><b>Download .csv File</b></span>'), | ||
downloadButton('downloadData', 'Download') | ||
) | ||
|
||
}) | ||
|
||
``` | ||
|
||
|
||
Column | ||
------------------------------------- | ||
|
||
|
||
### Uploaded Data (truncated to 50 rows) | ||
|
||
|
||
|
||
```{r} | ||
|
||
renderTable({ | ||
|
||
dat <- mydata() | ||
|
||
dat[] <- lapply(dat, as.character) | ||
|
||
dat %>% | ||
setNames(gsub('___', '_', colnames(.))) %>% | ||
head(50) | ||
|
||
}, digits = 2) | ||
|
||
``` | ||
|
||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.