Skip to content

Instantly share code, notes, and snippets.

View example within subject.csv
subject x color rep y
H 1 0 1 10.390916389674972
J 1 0 1 11.877635692199044
A 1 0 1 6.40831056135098
G 1 0 1 10.143656530161934
F 1 0 1 9.858462287495191
B 1 0 1 8.726973066068064
C 1 0 1 9.09479144777112
D 1 0 1 9.689029831578754
E 1 0 1 9.806302728246905
View How many p-values just under threshold.R
# simulate true effect sizes vs p in 0.01-0.05 range
library(tidyverse)
SUBJECT_COUNT = 16
TEST_COUNT = 16
# test if the p-value is in the specified range
inRange = function(p) {
(p > 0.01) & (p < 0.05)
}
View bootstrap per condition and plot with ggdist.R
library(tidyverse)
library(ggdist) # for stat_histinterval()
############# make the dataset ###################
# 1 sample per subject per condition
data_per_subject_condition = expand_grid(
subjectID = paste0("S", 1:50),
independent_variable_A = c("circle", "square"),
independent_variable_B = 1:3
@steveharoz
steveharoz / VR Gender.R
Created May 28, 2020
VR research - correlation between female participant proportion vs simulator sickness
View VR Gender.R
library(tidyverse)
# Mind the Gap:The Underrepresentation of Female Participants and Authors in Virtual Reality Research
# Tabitha C. Peck,Laura E. Sockol, and Sarah M. Hancock
# Table 3
data = read_csv(
"Study,N,CohensD,CI.Low,CI.Hi,p,SAMD,FemaleParticipants
Arafat et al. [4],16,0.42,0.19,0.65,<.001,−.07,81%
Ariza et al. [5],18,0.12,-0.09,0.33,0.263,−.68,22%
View sewer-covid19.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 8 columns, instead of 4. in line 8.
X,COVID-19 New Cases,Rep 1-N1,Rep 2-N1,Rep 1-N2,Rep 2-N2,Hospital admissions,virus RNA/ml
0,0.0,0.01771832019916774,0.025327583188293947,0.0012636319937241525,0.021536686448187715,0.22274881516587694,0.011848341232227562
1,0.0,0.01771832019916774,0.013927423563501674,0.0,0.01771832019916774,0.2819905213270144,0.014218009478673148
2,0.0,0.06076422295302489,0.10633738965673233,0.008872894878409794,0.006345630953625507,0.07819905213270138,0.06161137440758302
3,0.044047743576570264,0.0,0.1164739172696972,0.0012636319937241525,0.036727742012376295,0.22274881516587694,0.0
4,0.07024387534899187,0.15191055715279342,0.05950059026999374,0.0898827021364172,0.036727742012376295,0.2819905213270144,0.12796208530805683
5,0.022630983907802882,0.09240996608905253,0.08482817343043705,0.07342801384045856,0.08861906947427432,0.3388625592417062,0.08293838862559255
6,0.1726258132144233,0.17215614066131332,0.24558415520075633,0.28102079504903993,0.14682855819289167,0.22274881516587694,0.20616113744075823
7,0.0,0.15822871709356356,0
View attention check.R
library(tidyverse)
library(patchwork)
set.seed(8)
data = expand.grid(
x = 1:2,
subject = 1:20
) %>% mutate(y = runif(40))
@steveharoz
steveharoz / synethsized anscombe.R
Last active Aug 10, 2019
Synthesized Anscombe's quartet
View synethsized anscombe.R
library(tidyverse)
library(synthpop)
# make the built-in anscombe dataset tidy
anscombe_tidy = anscombe %>%
rowid_to_column("pointNumber") %>%
# pivot long
gather(setNumber, value, -pointNumber) %>%
# get the dimention and set number
mutate(dimention = substring(setNumber, 1, 1), setNumber = substring(setNumber, 2)) %>%
View inria phishing plot.R
library(tidyverse)
data = tribble(
~Site, ~Participants, ~Victims, ~Percent_Victims,
"Bordeaux", 137, 12, 8.8,
"Lille", 131, 9, 6.9,
"Lorraine", 268, 37, 13.8,
"Paris", 239, 23, 9.6,
"Rennes", 324, 33, 10.2,
"Rhone-Alpes", 219, 13, 5.9,
View spinner-plane.html
<body width="100%" height="100%">
<div class="core-page-loader">
<div class="plane-spinner">
<div class="spinner-plane"></div>
</div>
</div>
</body>
<style media="screen" type="text/css">
.core-page-loader {