Skip to content

Instantly share code, notes, and snippets.

@shadiakiki1986
shadiakiki1986 / README.md
Last active May 29, 2018 07:27
H2O driverless AI installation instructions

Installation scripts for H2O driverless AI

Launch order

  • install.sh (requires sudo)
    • need to exit and re-ssh into machine for "docker usage without sudo" to take effect
  • for GPU, refer to init-gpu.sh
  • dropbox.sh (optional)
  • start.sh
@stephlocke
stephlocke / app.R
Last active April 2, 2024 09:21
Demo shiny app for multiple file uploads and a single read step
library(shiny)
library(data.table)
ui <- fluidPage(
titlePanel("Multiple file uploads"),
sidebarLayout(
sidebarPanel(
fileInput("csvs",
label="Upload CSVs here",
multiple = TRUE)
@benmarwick
benmarwick / load_pkgs.R
Last active December 7, 2018 16:05
Providing CRAN packages in low- or no-bandwidth environments using miniCRAN as described in https://software-carpentry.org/blog/2015/03/teaching-in-yangon.html
## For the user with a new installation of R.
# They get a USB stick with a directory containing an .RProj file,
# the workshop files, and the local_CRAN directory. They open
# the .RProj, which sets the working directory for RStudio, and then
# they open this file and run it, which installs pkgs from
# the local_CRAN directory on the USB stick.
# Specify list of packages to install
pkgs <- c('ggplot2', 'rmarkdown', 'knitr')
@kdkorthauer
kdkorthauer / RstudioServerSetup.sh
Created October 7, 2016 15:04
Bash script to set up R, install a few R packages, and get Rstudio Server running on ubuntu.
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base libapparmor1 libcurl4-gnutls-dev libxml2-dev libssl-dev gdebi-core
sudo apt-get install libcairo2-dev
sudo apt-get install libxt-dev
sudo apt-get install git-core
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
belief y2015 y2014
Improves the security posture of my organization 0.75 0.71
Improves the security posture of the nations critical infrastructure 0.63 0.64
Reduces the cost of detecting and preventing cyber attacks 0.22 0.21
Improves situational awareness 0.60 0.54
Fosters collaboration among peers and industry groups 0.48 0.51
Enhances the timeliness of threat data 0.11 0.16
Makes threat data more actionable 0.21 0.24
@mick001
mick001 / neuralnetR.R
Last active November 26, 2023 19:12
A neural network exaple in R. Full article at: http://datascienceplus.com/fitting-neural-network-in-r/
# Set a seed
set.seed(500)
library(MASS)
data <- Boston
# Check that no data is missing
apply(data,2,function(x) sum(is.na(x)))
# Train-test random splitting for linear model
@pschwede
pschwede / iterable variable
Last active July 7, 2016 12:37
R example to show how to access a set of named variables e. g. generated by an iterable in a loop using paste() and assign().
# This is an example to show how to access a set of variables named e. g. by an iterable during an iteration.
#
# BE WARNED: The following coding strategy is not easy to debug!
#
# Some like to generate variables, rather than having just one list of all data sets.
# That way you get an introspectable object for each data set – which particularly eases debugging in RStudio.
# To create variables in a loop or other generative iterations R provides paste(), assign() and get().
# * With paste(), you can concatenate strings. (Use it to compose variable names.)
# * With assign(), you can give variables a value using their name in a string and of course the value you give.
# * With get() you can access such named variables using the sting.
@smithdanielle
smithdanielle / check.packages.r
Created April 1, 2014 13:23
Check if multiple R packages are installed. Install them if they are not,then load them into the R session.
# check.packages function: install and load multiple R packages.
# Check to see if packages are installed. Install them if they are not, then load them into the R session.
check.packages <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
# Usage example
@trestletech
trestletech / server.R
Last active February 2, 2022 09:47
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))
@psychemedia
psychemedia / README.md
Last active June 12, 2021 18:45
Example shiny app for loading in CSV file containing two location columns and an amount column and plotting great circle lines between each pair or points with line thickness related to amount. About: http://blog.ouseful.info/2014/03/24/experimenting-with-r-point-to-point-mapping-with-great-circles/