Skip to content

Instantly share code, notes, and snippets.

View cecilialee's full-sized avatar

Cecilia Lee cecilialee

View GitHub Profile
@cecilialee
cecilialee / highlight_input.r
Created May 8, 2018 08:41
Highlighted text input in Shiny #r #shiny
library(shiny)
ui <- fluidPage(
h2("Highlight Input Example"),
# sample text for selection
p("The insured received an examination of the large intestine in 2014.
As a result, everything was normal and there was no need to go back
to the follow-up consultation and any examination and treatment."),
@cecilialee
cecilialee / pdf_mongolite.r
Last active June 21, 2019 13:24
Read and write pdf to MongoDB with mongolite in R #r #mongolite
library(dplyr)
library(mongolite)
# MongoDB connection
m <- mongo("listcopro")
# Read raw data
file <- file("/Users/cecilialee/Dropbox/dropbox/freelance/listcopro/bitbucket/recruitment/test/data/resume_1.pdf", "rb")
data <- readBin(file, "raw", 9999999)
@cecilialee
cecilialee / iframe_app.r
Last active September 1, 2022 18:48
Embed iFrame in Shiny #r #shiny
library(shiny)
members <- data.frame(name=c("Name 1", "Name 2"), nr=c('BCRA1','FITM2'))
ui <- fluidPage(titlePanel("Getting Iframe"),
sidebarLayout(
sidebarPanel(
fluidRow(
column(6, selectInput("Member", label=h5("Choose a option"),choices=c('BCRA1','FITM2'))
))),
mainPanel(fluidRow(
@cecilialee
cecilialee / macbook_screenshot_location.sh
Created April 10, 2018 07:30
Change macbook screenshot save location.
defaults write com.apple.screencapture location /path/
@cecilialee
cecilialee / filter_all_text.R
Last active March 31, 2018 04:44
Filter text in any columns in R. #r
library(dplyr)
search <- "color"
iris %>%
filter_all(any_vars(grepl(search, ., ignore.case = TRUE)))
@cecilialee
cecilialee / dt_horizontal_scroll.R
Created March 26, 2018 23:04
Set horizontal sroll in DT::datatable in Shiny. #r #shiny
library(shiny)
library(DT)
ui <- fluidPage(
dataTableOutput("mtcars")
)
server <- function(input, output, session) {
output$mtcars <- renderDataTable(
datatable(mtcars, options = list(scrollX = TRUE))
@cecilialee
cecilialee / colored_icons_shiny.R
Last active March 23, 2018 09:51
Use colors on icons in Shiny. #r #shiny
library(shiny)
library(DT)
library(dplyr)
ui <- basicPage(
tags$style(".glyphicon-ok-sign {color:#2b8ee5}
.glyphicon-question-sign {color:#f4e107}
.glyphicon-exclamation-sign {color:#e5413b}
.glyphicon-flag, .glyphicon-trash {color:#28b728}"),
DT::dataTableOutput("table")
@cecilialee
cecilialee / icon_in_dt.R
Last active February 22, 2022 19:11
Use icons in DT datatable in Shiny. #r #shiny #dt
library(shiny)
library(DT)
library(dplyr)
ui <- basicPage(
DT::dataTableOutput("table")
)
server <- function(input, output, session) {
output$table <- DT::renderDataTable({
@cecilialee
cecilialee / condition_actions_app.R
Created March 19, 2018 10:11
Conditional actions in Shiny. #r #shiny
library(shiny)
library(shinyjs)
source("module.R")
# UI ==========================================================================
ui <- fluidPage(
useShinyjs(),
radioButtons("mode", "Mode",
choices = c("Entry" = "entry",
"Validation" = "validation"),
@cecilialee
cecilialee / parse_quoted_na.R
Created March 14, 2018 08:38
Parse quoted "NA" to NA in R. #r
df <- replace(df, df == "NA", NA)