Skip to content

Instantly share code, notes, and snippets.

getPackage <- function(pkg){
if(!require(pkg, character.only=TRUE)){
install.packages(pkg, dependencies=TRUE)
library(pkg, character.only=TRUE)
}
return(TRUE)
}
getPackages <- function(pkgs){
for (pkg in pkgs){
@javieroot
javieroot / Asset.R
Last active August 29, 2015 14:19 — forked from trcook/Asset.R
myfun <- function(x) deparse(substitute(x))
# so myfun(myQOG) will give output "myQOG"
library(data.table)
x <- data.table(A = c(3,2,1), B = 4:6)
y <- data.table(A = 1:4, C = 5:8)
z <- data.table(A = 2:3, D = 5:6)
tbls <- list(x, y, z)
lapply(tbls, function(i) setkey(i, A))
merged <- Reduce(function(...) merge(..., all = T), tbls)
@javieroot
javieroot / server.R
Created November 1, 2015 05:58 — 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({
if (USER$Logged == TRUE) {
@javieroot
javieroot / server.r
Created November 2, 2015 03:36 — forked from xiaodaigh/server.r
R Shiny Password Input
library(shiny)
shinyServer(function(input, output, session) {
# Partial example
output$meh <- renderPrint({
print("Meh --- ")
print(input$myTextInput )
print(input$passInput )
})
@javieroot
javieroot / #BenfordData.txt
Created November 2, 2015 04:14 — forked from calpolystat/#BenfordData.txt
Benford's Law and Data Examples: Shiny app at http://www.statistics.calpoly.edu/shiny
Benford's Law with Data Examples Shiny App
Base R code created by Jimmy Doi
Shiny app files created by Jimmy Doi
Cal Poly Statistics Dept Shiny Series
http://statistics.calpoly.edu/shiny
@javieroot
javieroot / server.R
Created November 2, 2015 04:25 — forked from xiaodaigh/server.R
A gist of programatically changing panel tabs in Shiny
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# Reactive expression to generate the requested distribution. This is
# called whenever the inputs change. The renderers defined
# below then all use the value computed from this expression
data <- reactive({
dist <- switch(input$dist,
@javieroot
javieroot / DESCRIPTION
Created November 2, 2015 04:55 — forked from wch/DESCRIPTION
conditionalPanel example for R Shiny
Type: Shiny
Title: conditionalPanel demo
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: conditionalpanel
DisplayMode: Showcase
@javieroot
javieroot / server.R
Created November 2, 2015 05:01 — forked from daroczig/server.R
Markdown preview via shiny, pandoc and rmarkdown
library(shiny)
library(rmarkdown)
shinyServer(function(input, output) {
output$html = reactive({
t <- tempfile()
cat(input$markdown, file = t)
@javieroot
javieroot / helpers.R
Created November 2, 2015 05:18 — forked from datalabgh/helpers.R
A shiny app for mining text
# load other helper files
# load textMiningTools function
source("textMiningTools.R", local=TRUE)
plotText <- function(fPath,
minWords,
scaleVec,
wordFreq,
plotType,
plotOptions,