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
#' Calculates rolling weeks backward from the end_date. | |
#' | |
#' The purpose is to group a vector of dates into 7 day weeks | |
#' backward in time. For example, if the end date was 2020-06-09, | |
#' the days 2020-06-03 through 2020-06-09 would be one week, | |
#' 2020-05-27 through 2020-06-02 would be another week, 2020-05-20 | |
#' through 2020-05-26 another and so on. The function will work even | |
#' if the vector of dates is missing one or more dates in the series. | |
#' | |
#' @param date_vector the vector of dates to group into weeks. Must be |
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: "Sample Lato .Rmd" | |
author: "Carl Frederick" | |
date: "11/12/2018" | |
mainfont: Lato | |
output: | |
pdf_document: | |
latex_engine: xelatex | |
--- |
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(babynames) | |
library(tidyverse) | |
set.seed(8746) | |
snames <- sample(babynames$name, 14) | |
unames <- snames[11:14] | |
snames <- snames[1:10] | |
Agency1 <- data_frame(Person = c(sample(snames, 5), unames[1]), |
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
#'dataMaid_cleanPlot.R | |
#' | |
#'These functions makes the default graphics prettier/easier to read: | |
#' | |
#' 1. Minimal Theme | |
#' 2. Angled Axis Text | |
#' | |
#' @example | |
cleanPlotHelper <- function(data, vnam, sideways) { |
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
#'dataMaid_isIDvar.R | |
#' | |
#'This function identifies "Key" and similar variables and stops dataMaid::makeDataReport from creating | |
#'visualizations and/or other inappropriate summaries. Instead it outputs a table with minimal information | |
#'(see https://cran.rstudio.com/web/packages/dataMaid/vignettes/extending_dataMaid.html for inspiration). | |
#' | |
#' @example | |
#' makeDataReport(toyData, output = "html", | |
#' preChecks = c("isKey", "isSingular", "isSupported", "isIDvar")) |
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(tidyverse) | |
library(DiagrammeR) | |
#Get package functions ---- | |
ls_fcns <- function(pkg) { | |
fcns <- unclass(lsf.str(envir = asNamespace(pkg), all = TRUE)) | |
return(as.character(fcns)) | |
} |
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
#Internal Functions | |
MYagsurv <- function(y, x, wt, risk, survtype=3, vartype=3) { | |
nvar <- ncol(as.matrix(x)) | |
status <- y[, ncol(y)] | |
dtime <- y[, ncol(y) - 1] | |
death <- (status == 1) | |
time <- sort(unique(dtime)) | |
nevent <- as.vector(rowsum(wt * death, dtime)) | |
ncens <- as.vector(rowsum(wt * (!death), dtime)) | |
wrisk <- c(wt * risk) #Had to add c() to remove the dimnames so that the multiplication later would work |