Skip to content

Instantly share code, notes, and snippets.

View HanjoStudy's full-sized avatar

HanjoStudy

  • Cape Town
View GitHub Profile
@HanjoStudy
HanjoStudy / ordinal_forest.R
Last active June 22, 2018 12:29
Ordinal_forest_caret (Work in Progress)
# install.packages("ordinalForest")
library(ordinalForest)
#
# start by naming my method to pass to train
#
ordinalForest <- list(type = "Classification",
library = "ordinalForest",
loop = NULL)
#
# define the tuning parameters
@HanjoStudy
HanjoStudy / useR2018.md
Last active November 10, 2023 02:07
useR2018 Material

I am looking forward to meeting you at the Tuesday AM (10th of July) tutorial session at useR2018!. We will be discussing a subject that I am very passionate about: Web Scraping!

The slides can be found here:

To ensure that we can be immediately productive on Tuesday morning, I would like you to get the following set up on your machines beforehand:

@HanjoStudy
HanjoStudy / chk_init.R
Last active October 25, 2018 23:07
Implementation of a print friendly method for selected `aws.ec2` functions
chk_init <- function(is_initialized, i, check = c("both", "running")){
while(!all(is_initialized)) {
for(ii in seq_along(i)) {
# Current instance
i_ii <- instance_status(i[[ii]])
# Initially, we don't get any information
if(length(i_ii) == 0) {
@HanjoStudy
HanjoStudy / RSelenium.R
Last active November 10, 2023 02:15
useR2018
##########################################################
#
# HANJO ODENDAAL
# hanjo.oden@gmail.com
# www.daeconomist.com
# @UbuntR314
# https://github.com/HanjoStudy
#
#
# ██████╗ ███████╗███████╗██╗ ███████╗███╗ ██╗██╗██╗ ██╗███╗ ███╗
@HanjoStudy
HanjoStudy / Rstudio_start.R
Last active August 1, 2018 21:51
Start multiple Selenium or Rstudio containers in script
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
library(purrr)
if (length(args)==0) {
stop("At least one argument must be supplied", call.=FALSE)
}
num_containers <- args[1]
@HanjoStudy
HanjoStudy / db_insert_table.R
Created October 8, 2018 08:51
Database_in_R
library(tidyverse)
library(RMySQL)
library(DBI)
library(dbplyr)
db_insert_table <- function(db_name, table_name, df){
db_user <- Sys.getenv("server_user")
db_password <- Sys.getenv("server_pass")
db_host <- "XXX"
db_dbname <- db_name
@HanjoStudy
HanjoStudy / xtract_multiclass.R
Created April 26, 2019 09:16
Cluster_utils.R
# Get the multiclass obs and prop
xtract_multiclass <- function(ctree_res){
tab <- sapply(1:length(ctree_res), function(id) {
y <- data_party(ctree_res[id])
y <- y[["(response)"]]
table(y)
})
@HanjoStudy
HanjoStudy / utils.R
Last active May 15, 2020 10:31
Util functions
#' @noRd
#' @export
split_df <- function(df, number){
n <- number
nr <- nrow(df)
split(df, rep(1:ceiling(nr/n),
each = n, length.out = nr))
}
@HanjoStudy
HanjoStudy / Dockerfile
Last active September 16, 2020 13:11
Shiny Proxy Server Setup
FROM openjdk:8-jre
RUN mkdir -p /opt/shinyproxy/
RUN wget https://www.shinyproxy.io/downloads/shinyproxy-2.3.0.jar -O /opt/shinyproxy/shinyproxy.jar
COPY application.yml /opt/shinyproxy/application.yml
WORKDIR /opt/shinyproxy/
CMD ["java", "-jar", "/opt/shinyproxy/shinyproxy.jar"]
function docker_rm_exits(){
sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
}
function docker_stop_rm(){
docker stop $1
docker rm $1
}