Plot:
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
#' Find every `scale_colour_*()` in the environment and remap it for a different colour-based aesthetic. | |
#' The new scale functions will be named `scale_[new_aesthetics]_*()`. | |
#' | |
#' @param new_aesthetics The name of one or more new colour-based aesthetics to create scales for | |
#' @rdname reuse_scale | |
#' @export | |
reuse_all_colour_scales <- function(new_aesthetics = c("fill")) { | |
new_aesthetic_name <- paste(new_aesthetics, collapse="") | |
# get colour scales | |
all_variable_names <- ls(envir = parent.env(current_env())) |
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(tidyverse) | |
# from https://github.com/matsukik/grt/blob/master/R/gaborPatch.R | |
gaborPatchTidy <- function( | |
spatial_frequency, | |
orientation_degrees = 0, | |
orientation_radians = (orientation_degrees * pi)/180, | |
peak_contrast = 1, | |
sigma = 1/6, # same for x and y | |
psi = 0, |
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(tidyverse) | |
library(foreign) # for read.spss() | |
library(ggdist) # for geom_dots() | |
# load the data | |
# source: https://osf.io/sd76g/ | |
data = foreign::read.spss("data_Experiment_4.sav", to.data.frame=TRUE) %>% | |
as_tibble() |
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(tidyverse) | |
library(lmerTest) | |
# subject count | |
COUNT = 5 | |
set.seed(8675309) | |
# generate a unique intercept per subject | |
data = tibble( |
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
# Extract all citation numbers such as [1] from a PDF's text | |
# It also includes cases for multiples [1, 3] and ranges [1-5] | |
# It tries to exclude confidence intervals by skipping | |
# | |
# written by Steve Haroz with help from ChatGPT | |
# MIT license | |
library(tidyverse) | |
library(pdftools) |
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
COUNT = 100000 | |
# How often does a single t-test of random data yield p<0.05? | |
replicate(COUNT, | |
t.test(rnorm(20))$p.value < 0.05 | |
) %>% mean() | |
#> 0.05073 | |
# 5% false positive rate |
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(tidyverse) | |
COUNT = 40 | |
data = tibble( | |
car = paste0(sample(LETTERS, COUNT, TRUE), sample(letters, COUNT, TRUE), sample(letters, COUNT, TRUE)), | |
value = rnorm(COUNT, 3), | |
group = c(rep("Petrol", COUNT/2), rep("Hybrid", COUNT/4), rep("Pure Electric", COUNT/8), rep("Diesel", COUNT/8)) | |
) |