🏳️🌈
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(faux) | |
within <- list( | |
pet = c("dog" = "Has a dog", "cat" = "Has a cat"), | |
time = c("day" = "Tested during the day", "night" = "Tested at night") | |
) | |
wcells <- faux:::cell_combos(within) | |
between <- list( | |
country = c("UK" = "United Kingdom", "NL" = "Nederland"), |
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(faux) | |
library(tidyverse) | |
inatt <- function(within, between, n, mu, sd, r, prop_bad = 0) { | |
good_n <- n * (1-prop_bad) | |
bad_n <- n * prop_bad | |
good_dat <- sim_design(within, between, n = good_n, mu, sd, r) | |
if (bad_n > 0) { | |
# should r be 0 for inattentive responders? | |
bad_dat <- sim_design(within, between, n = bad_n, unlist(mu)%>% mean(), sd, r) %>% |
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
#devtools::install_github("debruine/faux") | |
library(faux) | |
# make unique pairs of level names to ask for cors | |
unique_pairs <- function(v) { | |
if (is.numeric(v)) { v <- LETTERS[1:v] } | |
expand.grid(a = v, b = v) %>% | |
filter(a != b) %>% t() %>% | |
tibble::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
#' Check readline input | |
#' | |
#' @param prompt the prompt for readline | |
#' @param type what type of check to perform, one of c("numeric", "character", "length", "minlength", "maxlength", "exact", "grep") | |
#' @param compare the comparator for exact and (min|max)length types | |
#' @param ... other arguments to pass to grep | |
#' | |
#' @return the validated result of readline | |
#' @export | |
#' |
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(faux) | |
library(tidyverse) | |
data <- sim_design(within = list(T = c("T1", "T2", "T3", "T4", "T5")), | |
id = "ID") | |
processed_data <- data %>% | |
gather(T, raw, T1:T5) %>% # put in long format | |
group_by(ID) %>% # start doing calculations within groups | |
mutate(Mean_T = mean(raw), |
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
#devtools::install_github("debruine/faux") | |
library(faux) | |
library(afex) | |
library(tidyverse) | |
## Null data (no effect) | |
des_null <- check_design(list(task = c("test", "white", "asian")), | |
n = 400, | |
mu = c(100, 100, 90), |
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
#devtools::install_github("debruine/faux") | |
library(faux) | |
# compare the correlations between simulated normally distributed data and the likert-scale version | |
check_likert <- function(n = 100, r = 0.5, | |
prob = c(.05, .1, .2, .3, .2, .1, .05)) { | |
df <- faux::rnorm_multi(n, 2, 0, 1, r) %>% | |
dplyr::mutate( | |
L1 = norm2likert(X1, prob, 0, 1), | |
L2 = norm2likert(X2, prob, 0, 1) |
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' | |
output: html_document | |
--- | |
```{r, message=FALSE} | |
# load required packages | |
library("lme4") # model specification / estimation |
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(faux) | |
library(tidyverse) | |
sub_sd <- 1 # subject intercept SD | |
stim_sd <- 1 # stimulus intercept SD | |
err_sd <- 2 # residual error SD | |
grand.i <- 600 # grand interecpt (mean RT) | |
ord_eff <- 0.5 # coefficient of order effect | |
sch_eff <- 0.5 # coefficient of schizotypy effect | |
ord_sch_ixn <- 0.5 # coefficient of order*schizotypy interaction |
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
a <- rep(c(1, 2), each = 4) | |
b <- c(1,2,3,4,5,6,7,8) | |
frame <- data.frame(a,b) | |
library(dplyr) | |
library(tidyr) | |
x <- frame %>% | |
group_by(a) %>% | |
summarise(Mean = mean(b), |
OlderNewer