Skip to content

Commit

Permalink
v1.0.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
pgstevenson committed May 21, 2019
1 parent 5172cdf commit d1682ab
Show file tree
Hide file tree
Showing 58 changed files with 560 additions and 9,878 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
^data-raw$
^archive$
^\.git$
^config$
^scripts$
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ README.Rmd
# Ignore data files
/archive
/data-raw
<<<<<<< HEAD
inst/doc
inst/rmarkdown/templates/docx_letter
=======
>>>>>>> 5f675318c758311140ae387150324351c1da0776
39 changes: 19 additions & 20 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
Package: biometrics
Title: Report Templates for the Telethon Kids Institute
Version: 1.0.3.999
Version: 1.0.4
Authors@R: c(person("Paul", "Stevenson",
email = "Paul.Stevenson@telethonkids.org.au", role = c("aut", "cre")),
person("Matthew", "Cooper",
email = "Matt.Cooper@telethonkids.org.au", role = c("aut")))
Date: 2019-02-08
Date: 2019-05-21
Description: A pair of templates have been created that incorporate styling
themes present throughout the Telethon Kids Institute style guide, web page
and template documents. Currently, templates are available to produce
stand-alone HTML reports and ioslides presentations. These templates also
include colour palates that will automatically reproduce Telethon Kids style
in R graphics. A number of helper functions and data-sets are also available.
and template documents. Templates are available to produce stand-alone HTML
reports and ioslides presentations. These templates also include colour
palates that will automatically reproduce Telethon Kids style in R graphics.
A number of helper functions and data-sets are also available.
License: GPL-3 + file LICENSE
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.5.0)
Imports:
data.table (>= 1.11.4),
ggplot2 (>= 3.0.0),
dplyr (>= 0.7.6),
tidyr (>= 0.8.1),
readr (>= 1.1.1),
ggplot2 (>= 3.1.0),
dplyr (>= 0.8.0.1),
tidyr (>= 0.8.2),
readr (>= 1.3.1),
purrr (>= 0.2.5),
tibble (>= 1.4.2),
tibble (>= 2.0.1),
stringr (>= 1.3.1),
forcats (>= 0.3.0),
lubridate (>= 1.7.4),
yaml (>= 2.1.18),
XML (>= 3.98-1.11),
knitr (>= 1.20),
kableExtra (>= 0.9.0),
yaml (>= 2.2.0),
XML (>= 3.98-1.16),
knitr (>= 1.21),
kableExtra (>= 1.0.0),
GGally (>= 1.4.0),
broom (>= 0.5.0),
lme4 (>= 1.1-18-1),
broom (>= 0.5.1),
repmis (>= 0.5),
ProjectTemplate (>= 0.8.2),
igraph (>= 1.2.2)
igraph (>= 1.2.2),
jtools (>= 2.0.1)
Suggests:
rmarkdown (>= 1.10)
rmarkdown (>= 1.11)
VignetteBuilder: knitr
RoxygenNote: 6.1.1
16 changes: 10 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
# Generated by roxygen2: do not edit by hand

export(abbreviator)
export(format_model)
export(group_interval)
export(meansd)
export(nPer)
export(recoder)
export(roll_up)
export(round_df)
export(scale_color_telethonkids)
export(scale_fill_telethonkids)
export(telethonkids_colours)
export(telethonkids_cols)
export(telethonkids_pal)
export(telethonkids_palettes)
export(variable_rollup)
export(variables)
import(data.table)
import(dplyr)
import(ggplot2)
import(tibble)
import(tidyr)
importFrom(broom,tidy)
importFrom(data.table,shift)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_at)
importFrom(dplyr,select)
importFrom(grDevices,colorRampPalette)
importFrom(graphics,plot)
importFrom(igraph,components)
importFrom(igraph,graph_from_data_frame)
importFrom(igraph,layout_with_fr)
importFrom(lubridate,int_overlaps)
importFrom(lubridate,interval)
importFrom(magrittr,"%>%")
importFrom(stats,sd)
importFrom(tidyr,spread)
importFrom(utils,View)
importFrom(utils,read.delim)
importFrom(utils,write.table)
13 changes: 12 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# biometrics v1.0.4
* Updated HTML report template to better align with current workflow
- created analysis plan
- added markdown hooks to template
- plotly works 'out of the box'
- added 'recoder' to the templates
* Added format_model function
* Added excel_ref package data
* Moved telethonkids_colours and telethonkids_palletes in to package data
* Documentation updates

# biometrics v1.0.3
* Changed the logic behind group_interval, which should now be more robust
* Added abbreviator function that creates Bootstrap 4 tooltip with an abbreviation and its definition
* Added recoder function that reads a text files and saves with UTF-8 encoding
* Added round_df function that rounds dataframes to a specified number of decimal points
* Added round_df function that rounds data frames to a specified number of decimal points
* Some minor updates to html_report

# biometrics v1.0.2
Expand Down
5 changes: 2 additions & 3 deletions R/abbreviator.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
#'
#' @return a html anchor (i.e. <a ...>KEY</a>) defining a tooltip with the abbreviation's definition (defined in data.table column "def").
#'
#' @import data.table
#'
#' @examples
#' \dontrun{
#' library(data.table)
#'
#' abbrv <- data.table(abbrv = c("PGS"), def = c("Paul G Stevenson"), key = "abbrv")
#'
#' abbreviator("PGS", abbrv)
#'
#' }
#'
#' @export
Expand Down
76 changes: 62 additions & 14 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#' @title Excel column reference map
#' @description A data table of alpha/numeric key/value pairs, where key is the
#' Excel column reference map
#'
#' A data table of alpha/numeric key/value pairs, where key is the
#' letter sequence of the excel column. Range of letter sequence is A - ZZZ.
#' Usage: excel_ref["ABC"]$numbers that return the column number of that letter
#' sequence.
#'
#' @docType data
#'
#' @usage data(excel_ref)
#'
#' @format A data table with 18278 rows and 2 columns:
#' \describe{
#' \item{\code{letters}}{character Excel column reference letters}
#' \item{\code{numbers}}{integer corresponding column number}
#' }
#'
#' @examples
#' \donttest{
#' excel_ref["ABC"]$numbers
#' }
"excel_ref"

#' @title ICD-10 hash table
#' @description A data.table that maps ICD-10 classification code to the disease
#' name, disease category, parent category and disease group. Codes were
#' sourced from GNU Health (downloaded June-2018).
#' ICD-10 hash table
#'
#' A data.table that maps ICD-10 classification code to the disease
#' name, disease category, parent category and disease group. Codes were
#' sourced from GNU Health (downloaded June-2018).
#'
#' @docType data
#'
#' @usage data(ICD10)
#'
#' @format A data frame with 6820 rows and 5 variables:
#' \describe{
Expand All @@ -23,15 +37,21 @@
#' \item{\code{parent_category}}{character parent disease category}
#' \item{\code{disease_group}}{character Infections/notifiable}
#'}
#'
#' @source \url{http://health.gnu.org/}
"ICD10"

#' @title ICD-10-AM hash table
#' @description A data.table that maps ICD-10-AM classification code to the
#' disease name, disease category, parent category and disease group. ICD-10
#' codes were sourced from GNU Health (downloaded June 2018) and mappings to
#' ICD-10-AM were sourced from the Australian Consortium for Classification
#' Development (downloaded 8-June-2018).
#' ICD-10-AM hash table
#'
#' A data.table that maps ICD-10-AM classification code to the
#' disease name, disease category, parent category and disease group. ICD-10
#' codes were sourced from GNU Health (downloaded June 2018) and mappings to
#' ICD-10-AM were sourced from the Australian Consortium for Classification
#' Development (downloaded 8-June-2018).
#'
#' @docType data
#'
#' @usage data(ICD10AM)
#'
#' @format A data frame with 10680 rows and 7 variables:
#' \describe{
Expand All @@ -45,3 +65,31 @@
#'}
#' @source \url{https://www.accd.net.au/Downloads.aspx}
"ICD10AM"

#' Telethon Kids Institute colours
#'
#' Hex codes for the Telethon Kids colours per the 2014 Brand Style Guide.
#'
#' @docType data
#'
#' @usage data(telethonkids_colours)
#'
#' @format A named vector key = pantone matching system color, value = hex colour
#' code
"telethonkids_colours"

#' Telethon Kids Institute Palettes
#'
#' Telethon Kids colour palettes per the 2014 Brand Style Guide.
#'
#' @docType data
#'
#' @usage data(telethonkids_palettes)
#'
#' @format
#' \describe{
#' \item{\code{light}}{Light Colour Tone Palette}
#' \item{\code{dark}}{Dark Colour Tone Palette}
#' \item{\code{grey}}{Typography Palette}
#' }
"telethonkids_palettes"
6 changes: 3 additions & 3 deletions R/format_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ format_model <- function(x, effects = NULL, conf.level = 0.95, dp = 2) {
a <- broom::tidy(x, effects = effects, conf.int = T, conf.level = conf.level)
b <- a %>%
round_df(dp) %>%
dplyr::mutate(text1 = paste0(estimate, " (", 100 * conf.level, "% CI: ", conf.low, " to ", conf.high, ")"),
text2 = paste0("(", estimate, "; , ", 100 * conf.level, "% CI: ", conf.low, " to ", conf.high, ")")) %>%
dplyr::select(term, text1, text2)
dplyr::mutate(text1 = paste0(.data$estimate, " (", 100 * .data$conf.level, "% CI: ", .data$conf.low, " to ", .data$conf.high, ")"),
text2 = paste0("(", .data$estimate, "; , ", 100 * .data$conf.level, "% CI: ", .data$conf.low, " to ", .data$conf.high, ")")) %>%
dplyr::select(.data$term, .data$text1, .data$text2)
dplyr::left_join(a, b, by = "term")
}
18 changes: 10 additions & 8 deletions R/group_interval.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
#' @return an integer vector of group numbers
#'
#' @import dplyr
#' @importFrom igraph components graph_from_data_frame
#' @importFrom lubridate interval
#' @importFrom igraph components graph_from_data_frame layout_with_fr
#' @importFrom lubridate interval int_overlaps
#' @importFrom tidyr spread
#' @importFrom utils View
#' @importFrom graphics plot
#'
#' @examples
#'
Expand Down Expand Up @@ -45,12 +47,12 @@ group_interval <- function(dat, buffer, start, end, .view_mat = F, .view_graph =

dat <- dat %>%
mutate(rid = 1:nrow(dat),# add in row id
intervals = interval(interval_lower, interval_upper)) # define admissions as intervals incorporating buffer
intervals = interval(.data$interval_lower, .data$interval_upper)) # define admissions as intervals incorporating buffer

df_overlap <- bind_cols(
expand.grid(dat$rid, dat$rid), # make a 2 col table with every combination of id numbers
expand.grid(dat$intervals, dat$intervals)) %>% # make a combination of every interval
mutate(overlap = int_overlaps(Var11, Var21)) %>% # determine if intervals overlap
mutate(overlap = int_overlaps(.data$Var11, .data$Var21)) %>% # determine if intervals overlap
rename("row" = "Var1", "col" = "Var2")

# Find groups via graph theory See igraph package
Expand All @@ -59,15 +61,15 @@ group_interval <- function(dat, buffer, start, end, .view_mat = F, .view_graph =

# create a 2 column df with row (index) and group number, arrange on row number and return distinct values
df_groups <- data_frame(row = as.integer(names(groups)), group = groups) %>%
arrange(row) %>%
arrange(.data$row) %>%
distinct()

# View df
if (.view_mat) {
df_view <- df_overlap %>%
select(row, col, overlap) %>%
spread(key = col, value = overlap) %>% # turn into a n x n data_frame
select(-row)
select(.data$row, .data$col, .data$overlap) %>%
spread(key = .data$col, value = .data$overlap) %>% # turn into a n x n data_frame
select(-.data$row)
df_view[lower.tri(df_view, diag = F)] <- F # set lower triangle to FALSE (keep diagonals as TRUE)
apply(df_view, 2, function(x) ifelse(!x, NA, x)) %>% # change FALSE to NA
View()
Expand Down
22 changes: 20 additions & 2 deletions R/meansd.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#' meansd
#'
#' Return the mean and sd of a vector
#'
#' @param x a numeric vector
#' @param dpp (default 2) the number of decimal points to return the mean
#' @param dps (default 2) the number of decimal points to return the standard deviation
#'
#' @return A string the form of "mean (sd)" at the specified precision
#'
#' @importFrom stats sd
#'
#' @examples
#' \dontrun{
#' data(mtcars)
#'
#' meansd(mtcars$cyl)
#' }
#'
#' @export

meansd <- function(x, dpp=2, dps=2){
if(any(class(x)!="numeric" | class(x)!="interger")) {} else{print("Check you format")}
if(any(class(x)!="numeric" | class(x)!="interger")) {} else{print("Check your format")}
x <- as.numeric(x)
paste0(sprintf(paste0("%.",dpp,"f"), mean(x, na.rm=T)),
" (",
Expand Down
15 changes: 14 additions & 1 deletion R/nPer.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#' @title printing N and percentage
#' nPer
#'
#' Printing N and percentage
#'
#' @param vec numeric vector
#' @param intGroup xxxx
#' @param dp (default 1)
#'
#' @return xxxx
#'
#' @examples
#' \dontrun{
#' nPer(xxx)
#' }
#'
#' @export

Expand Down
5 changes: 2 additions & 3 deletions R/recoder.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#'
#' @param x path to the file
#'
#' @examples
#' @importFrom utils read.delim write.table
#'
#' @examples
#' \dontrun{
#'
#' recoder("packages.bib")
#'
#' }
#'
#' @export
Expand Down
1 change: 0 additions & 1 deletion R/roll_up.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#'
#' @return A data frame is returned with a id variable (matching the first column of the input data frame) and columns for values.
#'
#' @importFrom magrittr %>%
#' @import dplyr
#'
#' @examples
Expand Down
Loading

0 comments on commit d1682ab

Please sign in to comment.