Skip to content

Instantly share code, notes, and snippets.

Paul Stevenson pgstevenson

Block or report user

Report or block pgstevenson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View regresion_diagnostics.R
# Model Diagnostics
**Reference only, remove from report before sending to the sponsor**
### Influential Observations
```{r influence_plot, out.extra = "figure", echo = F, warning = F, message = F, comment = NA, eval = F}
influencePlot(mods$iris_data, id.method = "identify", main = "Influence Plot", sub = "Circle size is proportial to Cook's Distance" )
View confidence_interval.R
dat %>%
mutate(conf.low = estimate - std.err * qnorm((1 + 0.95)/2),
conf.high = estimate + std.err * qnorm((1 + 0.95)/2))
pgstevenson / hist2.R
Created Oct 2, 2019
Create a histogram with a normal distribution overlay in ggplot2
View hist2.R
hist2 <- function(x) {
dat <- tibble(x = x) %>%
ggplot(dat, aes(x = x)) +
geom_histogram(aes(y =..density..),
bins = 30,
colour = "black",
fill = "white") +
stat_function(fun = dnorm, args = list(mean = mean(dat$x), sd = sd(dat$x)))
pgstevenson / excel_date_dmy.R
Created Sep 24, 2019
Convert the number of days since 1989-12-30 to a dd/mm/yyyy character string
View excel_date_dmy.R
#' Excel Date dmy
#' Excel saves dates as the number of days since 1989-12-30. This needs to be
#' converted into a format that R can use. Unfortunatley, Excel doesn't always
#' store data in a column in the same way for all entries. This function looks
#' at the format of an input character string and if it can be converted to a
#' numeric format it converts the string to a dd/mm/yyyy format.
#' @param x an integer (either numeric or character class) representing a date
pgstevenson /
Created Sep 7, 2019
Configuration instructions to get CentOS 7 (minimal) installed on a VirtualBox for Docker

VirtualBox configuration (CentOS 7)

  • "Bridged Adapter", check "Cable Connected"

  • edit sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

    • Change to ONBOOT=yes
  • sudo service network start

  • sudo dhclient

  • sudo yum update

View navbar_toc.html
<link rel="stylesheet" href="">
<title>Navbar from TOC example</title>
<span id="nav"></span>
pgstevenson / similar_strings.R
Last active Sep 5, 2019
Calculate string distance(s) & group into networks
View similar_strings.R
#### libraries ----
# install.packages("intergraph")
pgstevenson / paste_clip.R
Created Sep 4, 2019
Function to paste data from clipboard into R
View paste_clip.R
paste_clip <- function(header = TRUE, ...) {
read.table("clipboard", sep = "\t", header = header, ...)
pgstevenson / copy_clip.R
Created Sep 4, 2019
Function to copy data from R to the clipboard
View copy_clip.R
copy_clip <- function(x, row.names = FALSE, col.names = TRUE, ...) {
write.table(x, "clipboard", sep = "\t", row.names = row.names, col.names = col.names, ...)
pgstevenson / quick_text.R
Last active Sep 16, 2019
Create text summaries of model output for paragraph insertion, models in lists
View quick_text.R
#' quick_text
#' improvements to biometrics::format_model
#' @param mod_list a list of regression models
#' @param effects (default NULL) a broom::tidy option e.g. "fixed", "random"
#' @param (default TRUE) a broom::tidy option to generate confidence intervals, logical
#' @param exponentiate (default FALSE) a broom::tidy optoin, logical
#' @param conf.level (default 0.95) the reported confidence interval of model estimates
#' @param dp (default 2) the number of decimal points reported in returned strings
You can’t perform that action at this time.