Skip to content

Instantly share code, notes, and snippets.

Avatar

Dean Attali daattali

View GitHub Profile
@daattali
daattali / reactive_time.R
Created May 13, 2017
Update the time in a tab every time the tab opens
View reactive_time.R
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
Turn selectize input into a tags input
View selectize-tags.R
# 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
Extremely basic bootstrap tagsinput wrapper in shiny
View shiny-bootstrap-tagsinput.R
# 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 Sep 29, 2016
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
View code-and-text-combo.R
# 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 Jan 14, 2021 — forked from withr/server.R
Encrypt password with md5 for Shiny-app.
View server.R
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 Jun 24, 2019
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
View rselenium-taxonomer-1-upload.R
# 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 Mar 30, 2018
Send a text message via email from R
View gmailr-text.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 Mar 5, 2016
Scraping Twitter and LinkedIn info in R
View linkedin.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 Feb 1, 2016
Little shiny apps used in my shinyjs tutorial http://bit.ly/shinyjs-slides
View 01_colourInput.R
# 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 Nov 26, 2015
Process BC Liquor Store data
View bcl-process.R
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,