Skip to content

Instantly share code, notes, and snippets.

View richarddmorey's full-sized avatar

Richard Morey richarddmorey

  • Cardiff University
  • Cardiff, Wales
View GitHub Profile
@richarddmorey
richarddmorey / missings_jags.R
Created December 23, 2016 13:27
Using JAGS to sample missing values in both DVs and IVs in Bayesian regression
set.seed(123) # make reproducible
M = 10000 # Number of posterior samples
N = 20
# sample the IV
x = rnorm(N, 10, 5)
# regression model for DVs
y = 100 + 3*x + rnorm(N,0,10)
## Delete missing data (3 in each)
@richarddmorey
richarddmorey / test_surveyjs.Rmd
Last active December 28, 2023 16:32
Testing SurveyJS and Rmarkdown
---
title: "Test SurveyJS and Rmarkdown"
output:
html_document:
css: "https://unpkg.com/survey-jquery/survey.min.css"
editor_options:
chunk_output_type: console
---
A test javascript survey by building a JSON object for [SurveyJS](https://surveyjs.io/).
@richarddmorey
richarddmorey / quarto_example.qmd
Created June 19, 2023 12:34
Encrypted knitr output using encryptRmd in a quarto html document
---
title: "Untitled"
format:
html:
embed-resources: true
---
<script src="https://code.jquery.com/jquery-3.7.0.min.js"
integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g="
crossorigin="anonymous"></script>
/opt/homebrew/bin/pandoc +RTS -K512m -RTS index.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --lua-filter /Users/saprm3/Library/Caches/org.R-project.R/R/renv/library/flexTeaching3.api-91d1a6f0/R-4.2/aarch64-apple-darwin20/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/saprm3/Library/Caches/org.R-project.R/R/renv/library/flexTeaching3.api-91d1a6f0/R-4.2/aarch64-apple-darwin20/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --verbose --variable bs3=TRUE --section-divs --template /Users/saprm3/Library/Caches/org.R-project.R/R/renv/library/flexTeaching3.api-91d1a6f0/R-4.2/aarch64-apple-darwin20/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/59/r7wjy0gn6yv59w19694x5gy80000gp/T//RtmpNWnHRc/rmarkdown-str16c6234aa443c.html
@richarddmorey
richarddmorey / planning_precision.Rmd
Created June 12, 2020 16:30
Figures for "Power and precision" blog post
---
title: "Power and precision"
author: "Richard D. Morey"
date: "11/06/2020"
output:
html_document:
dev: png
self_contained: no
editor_options:
chunk_output_type: console
@richarddmorey
richarddmorey / disgust_example.txt
Created December 4, 2022 15:37
Example data set from old learnbayes.org
"score" "condition"
13 "control"
26 "control"
30 "control"
23 "control"
34 "control"
37 "control"
33 "control"
34 "control"
35 "control"
@richarddmorey
richarddmorey / dice_rolling.R
Created July 14, 2022 11:32
Dice rolling significance test
library(dplyr)
library(memoise)
# Rolls
k = 3
# Sides
n = 5
sumDist = function(n,k,maxn = n){
do.call(
@richarddmorey
richarddmorey / showtext.Rmd
Created January 16, 2018 18:42
Demonstration of how to use other fonts in an Rmarkdown document
---
output:
html_document:
dev: svg
fig_width: 5
fig_height: 4
---
<!-- The output of this file can be found at
http://rpubs.com/richarddmorey/fonts
@richarddmorey
richarddmorey / create_covers.R
Last active May 13, 2022 11:25
Create image covers for PDFs
#' Create cover images for talks from a folder of PDFs
#'
#' Requires imagemagick to be installed and in the path for the convert command
#' @param pdf_dir Directory containing PDF files of papers
#' @param img_dir Directory to output all the image files
#' @param crop_height How big to make the cropped images, relative to full page
#' @param fade_height How much of the image to fade to transparent at the bottom
#' @param density resolution for PNG images
#'
create_covers = function(pdf_dir, img_dir, crop_height = .5, fade_height = .25, density = 300){
@richarddmorey
richarddmorey / testing_ricv.Rmd
Last active March 25, 2022 09:26
Testing the ricv package with Rmarkdown
---
title: "Testing ricv"
author: "Richard D. Morey"
date: "3/25/2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```