All my code is hosted on my GitHub page, but below are just some links to things I think are especially useful.

#### r Package for MCMC estimation of correlations

A simple r package for estimating correlations using MCMC. It’s build is such a way so that it’s maximally interchangeable with stats::cor.test function. It does this by just adding a new method method = "mcmc".

##### Installation

> devtools::install_github(bayesCorr)

##### Usage

require("ljcolling/bayesCorr"))


Next generate some data and run a the correlations

d = mvtnorm::rmvnorm(n = 10, mean = c(10,2), sigma = matrix(c(1,.5,.5,1), ncol = 2))
df = data.frame(x = d[,1], y = d[,2])
pearson.cor = cor.test(df$x,df$y, method = "pearson")
pearson.cor

##
## 	Pearson's product-moment correlation
##
## data:  x and y
## t = 2.7993, df = 8, p-value = 0.02322
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1325021 0.9238778
## sample estimates:
##       cor
## 0.7034425

mcmc.cor = cor.test(df$x,df$y, method = "mcmc")
mcmc.cor

##
## 	Bayesian parameter estimate of a correlation coefficient
##
## data:  x and y
## 95 percent highest density inveral:
## 0.1200436 0.9421377
## estimate:
## 	rho
## 0.7325132


The two objects should behave in much the same way.

pearson.cor$estimate  ## cor ## 0.7034425  mcmc.cor$estimate

##       rho
## 0.7325132

pearson.cor$conf.int  ## [1] 0.1325021 0.9238778 ## attr(,"conf.level") ## [1] 0.95  mcmc.cor$conf.int

## [1] 0.1200436 0.1200436
## attr(,"conf.level")
## [1] 0.95


#### r Package for interacting with OSF pages

An r package for interfacing with OSF data repositories. The purpose of this package is to be able to download data directly from OSF data storage nodes using only the node code. It makes use of the OSF API to do this. In order to use it you need to generate your own OSF token. This can be done from your settings page

##### Installation

To install this package you’ll need the devtools package in R. To install:

install.packages("devtools")


Following this, the osfconnect package can be installed with:

devtools::install_github("ljcolling/osfconnect")

##### Usage

The functionality of this package is very basic. It only downloads files from within OSF Storage. More advanced functionality will be added at a later date.

To connect to a node use:

 osfobj <- new.osfconnection(token = "mytokenstring", node = "thenode"


Then obtain a list of all the files with:

 osfobj$readStorageFiles()  You’ll now be able to view the list of files with: osfobj$files


Once you’ve found the filename of the file you want to download you can use,

osfobj\$downloadFile(filename)


#### r Package for sending email alerts

There are many r packages for sending emails, but most of them are a little fiddly to get working. This is meant to be a simple alternative that uses python 3 behind the scenes to get the job done is a way that should work right out of the box for at least in linux and macos machines. Note also, that it’s just setup to work with Gmail (because that’s what I use). It’s not intended as a generic email sending solution.

##### Installation

> devtools::install_github("ljcolling/PymaileR")

##### Usage
require("PymaileR")


You need to add your credentials to a hidden file called ~./.mail. You can do this at the r command prompt as follows (note: this is TidyVerse syntax, so change if you’re not living in the TidyVerse)

c("myname@gmail.com","mysupersecretpassword") %>% as.data.frame() %>% write_csv(path = "~/.mail",col_names = FALSE)

send.alert(subject = "Alert",message = "This is a test", toaddress = "test@email.com")
`