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
library(FRACTION) | |
fra(0.001, j = 20) | |
fra(0.5^10., j = 20) | |
gcd(14, 32) |
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
# Code by Ashe: https://stats.stackexchange.com/questions/184767/how-do-i-calculate-the-confidence-interval-of-an-icc | |
#Make some mocked data | |
library(lme4) | |
library(reshape2) | |
set.seed(2024) #For the Bell Riots | |
id <- factor(seq(1, 15)) | |
id.mu <- rnorm(15, 10, 5) | |
mydat <- NULL | |
for (a in 1:length(id)){ |
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
REM https://stackoverflow.com/questions/14304480/batch-resize-images-and-output-images-to-new-folder-with-imagemagick | |
magick mogrify -resize 1024 -quality 100 -path ./new *.jpg |
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
create_correlation <- function(n=1000, r=0.5) { | |
# Based on caracal:s answer at | |
# https://stats.stackexchange.com/questions/15011/generate-a-random-variable-with-a-defined-correlation-to-an-existing-variables/15040#15040 | |
theta <- acos(r) # corresponding angle | |
x1 <- rnorm(n, 1, 1) # fixed given data | |
x2 <- rnorm(n, 2, 0.5) # new random data | |
X <- cbind(x1, x2) # matrix | |
Xctr <- scale(X, center=TRUE, scale=FALSE) # centered columns (mean 0) | |
Id <- diag(n) # identity matrix | |
Q <- qr.Q(qr(Xctr[ , 1, drop=FALSE])) # QR-decomposition, just matrix Q |
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
favorite_packages <- c( | |
# Package development | |
"devtools", "Rcpp", "roxygen2", "testthat", "covr", | |
# Handle data | |
"rio", "tidyverse", "broom", "lubridate", "stringr", | |
# Database | |
"RMySQL", | |
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
library(tidyverse) | |
df <- read.csv("https://raw.githubusercontent.com/peterdalle/effectsizes/master/soc-psych.tsv", | |
header=TRUE, sep="\t", stringsAsFactors=FALSE) | |
df.comm <- read.csv("https://raw.githubusercontent.com/peterdalle/effectsizes-comm/master/effectsizes.csv", | |
header=TRUE, sep=",", stringsAsFactors=FALSE) | |
ggplot() + | |
geom_density(aes(df$r), fill="red", alpha=0.3) + |
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
library(gganimate) | |
library(ggrepel) | |
library(lubridate) | |
library(tidyverse) | |
# The order is FUBAR. | |
partycolors <- c("#006AB3", "#000077", "#52BDEC", "#E8112d", | |
"#83CF39", "#009933", "#DA291C", "#E8AC41") | |
# Mediearkivet keywords: |
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
library(tidyverse) | |
n.samples = 25 | |
set.seed(5) | |
rerun(20,rnorm(n.samples)) %>% | |
map_dfr(~data_frame(data = list(.x)), .id = 'samples') %>% | |
mutate(mu = map_dbl(data,mean), | |
se = map_dbl(data,~sd(.x)/sqrt(length(.x))), | |
top = mu +1.96*se, |
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
@echo off | |
REM From https://stackoverflow.com/questions/568564/how-can-i-view-live-mysql-queries | |
mysqladmin -u username -ppassword --verbose -i 1 processlist |
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
Include a DiagrammeR grViz() diagram into your RMarkdown document without the need to create a graph PDF file separately. | |
Based on the code from https://github.com/rich-iannone/DiagrammeR/issues/133#issuecomment-284370996. | |
```{r} | |
# Install packages. | |
install.packages(c("DiagrammeR", "DiagrammeRsvg", "rsvg", "magrittr")) | |
``` | |
```{r} |