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(tibble) | |
ilogit <- plogis # inverse logit | |
Df <- tibble(corpus = c('bnc_subset', 'subset'), | |
count = c(5242, 10092), | |
total = c(27449, 56355)) | |
M <- glm(cbind(count, total-count) ~ 0 + corpus, |
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(plotrix) | |
# WHat follows is a copy and paste from | |
# https://www.rdocumentation.org/packages/plotrix/versions/3.7/topics/gantt.chart | |
Ymd.format<-"%Y/%m/%d" | |
gantt.info<-list(labels= | |
c("First task","Second task","Third task","Fourth task","Fifth task"), | |
starts= | |
as.POSIXct(strptime( |
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(dplyr) | |
library(ggplot2) | |
library(tidyr) | |
library(pwr) | |
sample_sizes <- seq(5, 100, by=5) | |
effect_sizes <- c(0.1, 0.3, 0.5) | |
sample_one <- function(sequence){ | |
sample(size=1, sequence) |
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: "Python code chunks in RMarkdown" | |
author: "Mark Andrews" | |
date: "29 December 2017" | |
output: pdf_document | |
--- | |
Python and R code chunks in RMarkdown do not work the same. The R code chunks are all interpreted in one global environment, but the Python chunks are interpreted in independent environments. Also, I don't think there is any way to have Python inline code. | |
The following chunks try to illustrate this. |
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
import cPickle as pickle | |
ongoing_list_dict = dict(subject_1 = 7, | |
subject_7 = 42, | |
subject_101 = 3) | |
# Write the dictionary to file | |
with open('ongoing_list.pkl', 'wb') as f: | |
pickle.dump(ongoing_list_dict, f, protocol=2) |
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
# Some R code to demo boxplots, beanplots, pirateplots, etc | |
library(psych) | |
library(dplyr) | |
library(tidyr) | |
library(beanplot) | |
library(yarrr) | |
# Load the cushny data | |
data(cushny) |
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
#################################### | |
example.colors <- c('cyan', | |
'darkgoldenrod', | |
'cornflowerblue', | |
'chocolate1', | |
'chartreuse1') | |
myplot <- function(N, example.colors, drift=0.1, switch.p=0.01){ | |
K <- length(example.colors) |