Skip to content

Instantly share code, notes, and snippets.

View darokun's full-sized avatar

Daloha Rodriguez-Molina darokun

  • Munich, Germany
View GitHub Profile
@darokun
darokun / clean_adobe_connect_session_grading_data.R
Created April 27, 2018 11:04
This is a gist to clean the spreadsheet containing grades for my students on Adobe Connect sessions
library(tidyverse)
library(readxl)
library(stringr)
xl_data <- read_excel("Feedback_Job_Interview.xlsx")
col_names <- c("student", "date", "preparation", "fluency", "grammar", "vocabulary", "questions", "grade", "comments")
colnames(xl_data) <- col_names
# Based on this blog post: https://www.r-bloggers.com/updating-r/
### 1
## Change accordingly
list_dir <- "/Library/Frameworks/R.framework/Resources/library"
## Get the list of installed packages
installed <- dir(.libPaths())
## Save the list for later use
@darokun
darokun / berlin_wall.R
Created February 6, 2018 08:31
Has the Berlin Wall been down longer than it stood? By how much?
construction <- as.Date("1961-08-13")
fall <- as.Date("1989-11-09")
now <- as.Date("2018-02-06")
now-fall > fall-construction
fall-construction
now-fall
@darokun
darokun / distinctColors.R
Last active August 1, 2020 04:53
Generating different and distinct colors in R
library(RColorBrewer)
qual_col_pals <- brewer.pal.info[brewer.pal.info$category == 'qual',]
col_vector <- unlist(mapply(brewer.pal, qual_col_pals$maxcolors, rownames(qual_col_pals)))
#check
myunif <- runif(40, 1, 1)
barplot(myunif, col = col_vector)
@darokun
darokun / SqTri.R
Created February 23, 2017 13:20
Finding square numbers that are also triangular numbers
# Finding square numbers that are also triangular numbers
# This snippet of code has been inspired by Matt Parker's book: Things to make and do in the fourth dimension, Chapter 3, pg. 50
# Square numbers
SqNum <- function(to, from = 1) {
x <- NULL
for(i in seq(from = from, to = to)) {
x[i] <- i^2
}
@darokun
darokun / shadenorm.R
Last active November 5, 2015 15:14 — forked from tony91782/shadenorm.R
## -------------------------- ##
## An R Function that Shades ##
## under a normal density. ##
## ##
## This is a convenience ##
## function for polygon() ##
## -------------------------- ##
shadenorm = function(below=NULL, above=NULL, pcts = c(0.025,0.975), mu=0, sig=1, numpts = 500, color = "gray", dens = 400,
lines=FALSE,between=NULL,outside=NULL){