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
REM This file converts all of the Markdown files to HTML. | |
REM Converting in the current directory | |
REM %%~ni returns just the filename of %%i, not its extension | |
for %%i in (*.markdown) do pandoc -f markdown -t html5 %%~ni.markdown > html/%%~ni.html | |
REM Converting a subdirectory - just slap it on front | |
for %%i in (report_pages/*.markdown) do pandoc -f markdown -t html5 report_pages/%%~ni.markdown > html/report_pages/%%~ni.html |
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) | |
df_list <- list( | |
mutate(mtcars[1:5, ], jurisdiction = 'New Guernsey'), | |
mutate(iris[1:5, ], mean = mean(Sepal.Length)), | |
mutate(beaver1[1:5, ], jurisdiction = 'New Guernsey', mean = mean(temp)) | |
) |
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
@media print { | |
tr{ | |
page-break-after: always; | |
display: block; | |
} | |
} |
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
# Calculate age at a given reference date | |
# Create an interval between the date of birth and the enrollment date; | |
# intervals are specific to the two dates. Periods give the actual length | |
# of time between those dates, so convert to period and extract the year. | |
calc_age <- function(birthDate, refDate = Sys.Date(), unit = "year") { | |
require(lubridate) | |
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
# The incantation | |
options(stringsAsFactors = FALSE) | |
library(ggplot2) | |
# Some sample data | |
# A test that can result in a negative or positive only | |
testres2 <- data.frame(result = c("Negative", "Positive"), |
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(rvest) | |
# Get the list of files to work on | |
files_to_process <- list.files('r:/shared documents/', | |
pattern = 'html', | |
full.names = TRUE) | |
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
# Two main things I can't figure out: | |
# 1. How do I get the name of each function to prefix its log entry? | |
# e.g., INFO:testmodule:outsideFun:{msg} instead of just INFO:testmodule:{msg} | |
# 2. How do I get bound values to persist through subsequent functions? | |
# e.g., user:matt.parker and outsideArg:foo should appear in both | |
# outsideFun and insideFun log messages | |
import logging |
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
options(stringsAsFactors = FALSE, | |
scipen = 9999) | |
library(shiny) | |
library(ggplot2) | |
library(dplyr) |
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) | |
# Set up a temp sqlite database | |
db <- src_sqlite(tempfile(), create = TRUE) | |
iris2 <- copy_to(db, iris) | |
# if_else with named true and false on a data.frame -> no problem | |
iris %>% mutate(Sepal.Size = if_else(Sepal.Length > 5, | |
true = "big", |
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
# Always | |
options(stringsAsFactors = FALSE) | |
library(tidyverse) | |
# Setting the ggplot2 theme |
NewerOlder