This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(microbenchmark) | |
x = sample(c("less often", "1", "2", "3", "4", "4+"), 1e6, r = TRUE) | |
fun1 = function(x) { | |
case_when( | |
x == "less often" ~ 1L, | |
x %in% c("1", "2") ~ 2L, | |
x %in% c("3", "4") ~ 3L, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
import os | |
from subprocess import Popen, PIPE | |
import datetime | |
import time | |
from celery import Celery | |
from celery import states | |
from os.path import dirname, join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this in the project repo from the command-line | |
# http://stackoverflow.com/a/4593065/99923 | |
git log --shortstat --author "Xeoncross" --since "2 weeks ago" --until "1 week ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(data.table) | |
size = 1e6 | |
resample <- function(x,size = 1e6) sample(x,size,replace = TRUE) | |
text <- c("Canada","Peru","Australia","Angola","France","", NA_character_) | |
text2 <- c("Oh Canada.","Arriba Peru.","Australia?","Vive la France.") | |
numerics <- rnorm(1e6) | |
dt <- data.table( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df <- structure(list(Year = c("2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2015", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016"), | |
Response = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L), | |
.Label = c("Trustworthy", "Supportive", "Leading", "Strong", "Dependable", "Consultative", "Knowledgeable", "Sensible", "Intelligent", "Consistent", "Stable", "Innovative", "Aggressive", "Conservative", "Visionary", "Arrogant", "Professional", "Responsive", "Confident", "Accessible", "Timely", "Focused", "Niche", "None"), class = "factor"), Proportion = c(0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(microbenchmark) | |
plus_test <- function(x) { | |
return(+x) | |
} | |
asint_test <- function(x) { | |
return(as.integer(x)) | |
} | |
test_me <- function(n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
current_test <- function(df) { | |
for (i in 1:nrow(df)) { # for every row | |
if ((df[i, 'col1'] + df[i, 'col2'] + df[i, 'col3'] + df[i, 'col4']) > 4) { # check if > 4 | |
df[i, 5] <- "greater_than_4" # assign 5th column | |
} else { | |
df[i, 5] <- "lesser_than_4" # assign 5th column | |
} | |
} | |
return(df[,5]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Test" | |
author: "Brandon Bertelsen" | |
date: "January 7, 2016" | |
output: | |
tufte::tufte_html: default | |
--- | |
```{r setup, include=FALSE} | |
library(tufte) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title : Example Report | |
subtitle: Subtitle | |
job : Slidify 2013 | |
mode: standalone # {standalone, draft} | |
--- | |
{r init, echo=FALSE,message=FALSE, warning = FALSE, cache=FALSE} | |
opts_chunk$set(echo=FALSE, | |
message=FALSE, |
NewerOlder