Skip to content

Instantly share code, notes, and snippets.

View daattali's full-sized avatar

Dean Attali daattali

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / layout_change.R
Created May 13, 2017 20:16
Change the width of the main panel depending on what tab is open
library(shiny)
ui <- fluidPage(
shinyjs::useShinyjs(),
# You have to include this one-liner CSS
tags$style(".fullwidth { width: 100% !important; }"),
# You need to wrap the sidebarLayout() by a div() and give it an ID
div(id = "SOMEID",
# I'm trying to let the user select points and paint them in a certain colour, and if the user clicks on a point then paint that point a different colour.
# It looks like the pointNumber and curveNumber data that plotly returns are different for the same points. I'm not sure how curveNumber works, but to me it doesn't make sense yet :)
# Any help is appreciated!
library(plotly)
library(shiny)
ui <- fluidPage(
plotlyOutput("plot")
)
# Clicking on a single point seems to clear the lasso selection. But the opposite is not true: doing a lasso selection still keeps the clicked point information.
# To reproduce:
# - Click a single point
# - Do a lasso selection
# - Both are currently visible
# - Click a different point
# - Now the lasso selection information is gone
# - Do a lasso selection again, both are visible again
library(shiny)