This file contains hidden or 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
use_eupl <- function() { | |
EUPL_BZIP2 <- as.raw(c(0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, | |
0x59, 0xfb, 0x2b, 0x04, 0x38, 0x00, 0x04, 0xb0, 0x5f, 0xf5, 0x00, | |
0x10, 0x48, 0xff, 0xff, 0xf9, 0x3f, 0xf7, 0xfe, 0xa0, 0x3f, 0xff, | |
0xff, 0xf0, 0x40, 0x00, 0x04, 0x60, 0x00, 0x20, 0x18, 0x00, 0x10, | |
0x00, 0x60, 0x16, 0xfd, 0x35, 0xaf, 0xb7, 0x68, 0x28, 0x03, 0xd0, | |
0x00, 0x1e, 0x95, 0x7b, 0xeb, 0x2f, 0xbe, 0xe3, 0x59, 0x73, 0xaa, | |
0xa4, 0xfa, 0x5e, 0x87, 0xb4, 0x29, 0x5e, 0xde, 0x62, 0xed, 0xb1, | |
0xec, 0x68, 0x96, 0xdb, 0xde, 0xd5, 0xd9, 0xb5, 0xb6, 0xd6, 0x16, | |
0x3a, 0xee, 0xef, 0x4f, 0x5a, 0xeb, 0xdd, 0xb9, 0xe9, 0x4f, 0x0c, |
This file contains hidden or 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
require(rang) | |
require(purrr) | |
require(igraph) | |
convert_edgelist <- function(x) { | |
output <- data.frame(x = x$pkg, y = rang:::.extract_queryable_dependencies(x$original, x$no_enhances, x$no_suggests)) | |
for (dep in x$deps) { | |
if (!rang:::.is_terminal_node(dep, x$no_enhances)) { | |
el <- data.frame(x = unique(dep$x_pkgref), y = rang:::.extract_queryable_dependencies(dep, x$no_enhances, x$no_suggests)) | |
output <- rbind(output, el) |
This file contains hidden or 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
require(tidyverse) | |
require(tidyr) | |
require(moments) | |
nrespondants <- c(223, 41, 63, 86, 64, 251, 82, 73, 74, 17, 64, 168, 43, 47, 64, 35, 135, 28, 15, 43, 10, 43, 366, 45, 73, 50, 26, 121, 25, 38, 44, 5, 46, 260, 36, 54, 49, 31, 63, 26, 30, 29, 3, 44) | |
score <- rep(0:10, 4) | |
wave <- sort(rep(1:4, 11)) |
This file contains hidden or 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
require(R6) | |
dog <- list(name = 'hundno', say = 'whhooo!') | |
class(dog) <- "animal" | |
cat <- list(name = 'kitty', say = 'meow!') | |
class(cat) <- "animal" | |
ipad <- list(name = "iPad mini") | |
class(ipad) <- "computer" |
This file contains hidden or 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
var click_score_pos = function(rev_id, pos) { | |
var reviews = document.querySelector("div[role='presentation'].x-grid3-body").querySelectorAll('tr'); | |
tds = reviews[rev_id].querySelectorAll('td') | |
for (var key of tds.keys()) { | |
if (tds[key].getAttribute('class').includes('wrong')) { | |
var exId = key; | |
} | |
} | |
tds[exId + pos].click() | |
// sleep(2000) |
This file contains hidden or 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
gendf <- function() { | |
a <- data.frame(x = rnorm(200, 1, 1), y = rnorm(200, 3, 1)) | |
b <- data.frame(x = rnorm(200, 9, 1), y = rnorm(200, 10, 1)) | |
z <- c(rep(1, 200), rep(2, 200)) | |
cbind(rbind(a, b), z)[sample(1:400),] | |
} | |
df1 <- gendf() | |
df2 <- gendf() |
This file contains hidden or 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
## prereq: | |
## 1) How to define a function | |
## Security level | |
## Warning: Does not stop execution | |
## Error: Stop execution | |
## example of warning | |
log(-1) |
This file contains hidden or 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
# github.com/chainsawriot | |
import os, sys | |
from selenium import webdriver | |
import selenium.webdriver.support.ui as ui | |
from selenium.webdriver.common.keys import Keys | |
# your facebook username and password | |
USERNAME = "" |
This file contains hidden or 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
require(dplyr) | |
require(magrittr) | |
# 95% CI: assume normally distributed | |
read.table("rainstorm.fwf") %>% mutate(hr = V6 + (V7/60)) %>% group_by(V1) %>% summarise(meanhr = mean(hr), sehr = sqrt(var(hr)/(length(hr)-1)), lowerCI = meanhr - (1.96*sehr), upperCI = meanhr + (1.96*sehr)) | |
# Median and 2.5 and 97.5 percentile. Mean > Median, the data is positive skew and mean will overestimate the central tendency. Use median for robustness | |
read.table("rainstorm.fwf") %>% mutate(hr = V6 + (V7/60)) %>% group_by(V1) %>% summarise(medianhr = median(hr), lowerqhr = quantile(hr, probs = 0.025), upperqhr = quantile(hr, probs = 0.975)) |
This file contains hidden or 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
iris[c(3,2,1),] # index the dataframe by an "indices vector", will only pick the first three rows in reversed order | |
order(iris$Sepal.Length) # generate an "indices vector" based on the ranked value of Sepal Length | |
# therefore | |
iris[order(iris$Sepal.Length, decreasing=TRUE),] | |
# is ordered by row based on the value of Sepal Length, you still need to specify the column required. | |
# try these also |
NewerOlder