Skip to content

Instantly share code, notes, and snippets.

View daattali's full-sized avatar

Dean Attali daattali

View GitHub Profile
@daattali
daattali / reactive_time.R
Created May 13, 2017 20:13
Update the time in a tab every time the tab opens
library(shiny)
ui <- fluidPage(
tabsetPanel(
id = "maintabs",
tabPanel(
"tab1",
"Current time is",
textOutput("time_out", inline = TRUE)
),
@daattali
daattali / selectize-tags.R
Created May 6, 2017 19:20
Turn selectize input into a tags input
# This can be improved in a few ways easily:
# - make this into a function so you don't need to know all the parameters
# - use CSS to not show the dropdown that keeps popping up to "add" each item
library(shiny)
ui <- fluidPage(
selectizeInput("select", "Select", c(),
multiple = TRUE, options = list(
'create' = TRUE,
'persist' = FALSE)
@daattali
daattali / shiny-bootstrap-tagsinput.R
Last active May 5, 2017 23:43
Extremely basic bootstrap tagsinput wrapper in shiny
# http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
library(shiny)
tagsinput <- function(tag) {
tag$children[[2]] <- tagAppendAttributes(tag$children[[2]],
`data-role` = "tagsinput")
tag
}
@daattali
daattali / code-and-text-combo.R
Created September 29, 2016 09:57
An attempt to have a way to create the code for an output only once, and be able to both display it and its code
# Disclaimer: I'm a noob at NSE and this implementation is just something I whipped up in 5 minutes at 3am.
# So if it's terrible, no judging!
library(shiny)
library(ggplot2)
ui <- fluidPage(
colourpicker::colourInput("col", "Select colour", "red"),
plotOutput("plot"),
verbatimTextOutput("code")
@daattali
daattali / server.R
Last active January 14, 2021 04:42 — forked from withr/server.R
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
@daattali
daattali / rselenium-taxonomer-1-upload.R
Last active June 24, 2019 09:00
Use RSelenium to automatically upload many FASTQ files, submit each to "full analysis" when it's ready, and download the analyzed file on Taxonomer.com
# This script uploads all the FAST files to the taxonomer server (only one file can be uploaded at a time)
# Assumes that you have RSelenium package installed and that you've got a simple selenium example to work
if (FALSE) {
fastq_files <- c(
list.files(# WHERE ARE THE FILES?, pattern = "fastq.gz$", full.names = TRUE)
)
login_password <- "" # what is my password???
library(RSelenium)
@daattali
daattali / gmailr-text.R
Last active March 30, 2018 00:02
Send a text message via email from R
library(shiny)
library(gmailr)
ui <- fluidPage(
textInput("subj", "Subject", "Schedule change"),
textInput("text", "Message"),
actionButton("btn", "Send")
)
server <- function(input, output, session) {
@daattali
daattali / linkedin.R
Created March 5, 2016 11:11
Scraping Twitter and LinkedIn info in R
# Get a person's name, location, summary, # of connections, and skills & endorsements from LinkedIn
# URL of the LinkedIn page
user_url <- "https://www.linkedin.com/in/daattali"
# since the information isn't available without being logged in, the web
# scraper needs to log in. Provide your LinkedIn user/pw here (this isn't stored
# anywhere as you can see, it's just used to log in during the scrape session)
username <- "yourusername"
password <- "yourpassword"
@daattali
daattali / 01_colourInput.R
Last active February 1, 2016 00:16
Little shiny apps used in my shinyjs tutorial http://bit.ly/shinyjs-slides
# See http://daattali.com/shiny/colourInput/ for more demos
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
colourInput("col", "Colour", "blue")
# colourInput("col", "Colour", "#ff0000",
# palette = "limited", showColour = "background")
@daattali
daattali / bcl-process.R
Created November 26, 2015 07:07
Process BC Liquor Store data
library(dplyr)
rawDataUrl <- "http://pub.data.gov.bc.ca/datasets/176284/BC_Liquor_Store_Product_Price_List.csv"
bcl <- read.csv(rawDataUrl, stringsAsFactors = FALSE)
products <- c("BEER", "REFRESHMENT BEVERAGE", "SPIRITS", "WINE")
bcl <- dplyr::filter(bcl, PRODUCT_CLASS_NAME %in% products) %>%
dplyr::select(-PRODUCT_TYPE_NAME, -PRODUCT_SKU_NO, -PRODUCT_BASE_UPC_NO,
-PRODUCT_LITRES_PER_CONTAINER, -PRD_CONTAINER_PER_SELL_UNIT,
-PRODUCT_SUB_CLASS_NAME) %>%
rename(Type = PRODUCT_CLASS_NAME,
Subtype = PRODUCT_MINOR_CLASS_NAME,