From 6cff6ed75c763f3dba1c7ffef6183397fb16d9ee Mon Sep 17 00:00:00 2001 From: Milan Wiedemann Date: Wed, 7 Jul 2021 10:30:15 +0100 Subject: [PATCH] add documentation --- DESCRIPTION | 11 +- docs/404.html | 2 +- docs/CODE_OF_CONDUCT.html | 2 +- docs/LICENSE-text.html | 2 +- docs/LICENSE.html | 2 +- docs/authors.html | 2 +- docs/index.html | 10 +- docs/pkgdown.yml | 4 +- docs/reference/as_age_groups.html | 203 ++++++++++++++++++++++++++ docs/reference/calc_monthly_freq.html | 181 +++++++++++++++++++++++ docs/reference/ggplotly_nottshc.html | 184 +++++++++++++++++++++++ docs/reference/hash.html | 2 +- docs/reference/index.html | 26 +++- docs/reference/sample_vector.html | 186 +++++++++++++++++++++++ docs/reference/theme_nottshc.html | 2 +- 15 files changed, 805 insertions(+), 14 deletions(-) create mode 100644 docs/reference/as_age_groups.html create mode 100644 docs/reference/calc_monthly_freq.html create mode 100644 docs/reference/ggplotly_nottshc.html create mode 100644 docs/reference/sample_vector.html diff --git a/DESCRIPTION b/DESCRIPTION index 5637dd8..bc9a3c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nottshcMethods Title: Helper functions for working with NHS healthcare data by the Data Science Team of the Nottinghamshire Healthcare NHS Foundation Trust -Version: 0.1.0 -Date: 2021-03-29 +Version: 0.2.0 +Date: 2021-07-07 Authors@R: c( person("Milan", "Wiedemann", email = "milan.wiedemann@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1991-282X")), person("Zoe", "Turner", role = c("aut"), comment = c(ORCID = "0000-0003-1033-9158")), @@ -17,3 +17,10 @@ RoxygenNote: 7.1.1 Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 +Imports: + dplyr, + tidyr, + plotly, + scales, + ggplot2, + lubridate diff --git a/docs/404.html b/docs/404.html index 5d071b6..14c5f16 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ nottshcMethods - 0.0.1 + 0.2.0 diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html index c4e11b2..a17546a 100644 --- a/docs/CODE_OF_CONDUCT.html +++ b/docs/CODE_OF_CONDUCT.html @@ -71,7 +71,7 @@ nottshcMethods - 0.0.1 + 0.2.0 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 19b8dc4..08e3152 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -71,7 +71,7 @@ nottshcMethods - 0.0.1 + 0.2.0 diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 029c35d..e1c21f0 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -71,7 +71,7 @@ nottshcMethods - 0.0.1 + 0.2.0 diff --git a/docs/authors.html b/docs/authors.html index 1e2041d..9f90613 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ nottshcMethods - 0.0.1 + 0.2.0 diff --git a/docs/index.html b/docs/index.html index ad37c0c..a426f40 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,7 +31,7 @@ nottshcMethods - 0.0.1 + 0.2.0 @@ -71,7 +71,13 @@

You can install the the development version from GitHub with:

 # install.packages("devtools")
-devtools::install_github("CDU-data-science-team/nottshcMethods")
+devtools::install_github("CDU-data-science-team/nottshcMethods") + +
+

+Nottinghamshire Healthcare NHS Foundation Trust slides

+

Once the package is installed, xaringan presentation slides with Nottinghamshire Healthcare NHS Foundation Trust branding can be access easily using the RStudio IDE, by selecting File -> R markdown ... -> From Template.

+

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index bc3b32c..b85a230 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,6 +1,6 @@ -pandoc: 2.11.2 +pandoc: 2.11.4 pkgdown: 1.6.1 pkgdown_sha: ~ articles: {} -last_built: 2021-03-29T13:00Z +last_built: 2021-07-07T09:17Z diff --git a/docs/reference/as_age_groups.html b/docs/reference/as_age_groups.html new file mode 100644 index 0000000..ed0abf1 --- /dev/null +++ b/docs/reference/as_age_groups.html @@ -0,0 +1,203 @@ + + + + + + + + +Categorise continuous age into age groups — as_age_groups • nottshcMethods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Categorise continuous age into age groups

+
+ +
as_age_groups(
+  var,
+  min = 0,
+  max = 100,
+  by = 10,
+  grouping_method = c("user_defined", "ons_1", "ons_2", "nhs_survey")
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
var

Name of variable or vector

min

Numeric, specifying the minimum age of the first age group. +Age values lower than this will be returned as missing values (NA)

max

Numeric, specifying the upper end of the last age group

by

Numeric, increment of the age categories

method

String, specyfing the method to be used for grouping age into categories. +Details about the different methods are available here: +"user_defined", "ons_1", "ons_2", "nhs_survey" ... TODO

+ +

Value

+ + + + + +

Examples

+
# Example using a vector: +set.seed(123) +age <- sample(1:100, 100, replace = T) +as_age_groups(age) +
#> [1] 30-39 70-79 50-59 10-19 60-69 40-49 50-59 40-49 10-19 20-29 90-99 90-99 +#> [13] 60-69 90-99 50-59 90-99 0-9 90-99 90-99 70-79 20-29 0-9 40-49 0-9 +#> [25] 80-89 30-39 70-79 80-89 40-49 70-79 10-19 30-39 0-9 0-9 40-49 70-79 +#> [37] 20-29 20-29 60-69 50-59 0-9 50-59 20-29 90-99 30-39 80-89 30-39 90-99 +#> [49] 60-69 70-79 70-79 60-69 10-19 80-89 90-99 90-99 20-29 30-39 20-29 70-79 +#> [61] 40-49 40-49 90-99 60-69 90-99 10-19 90-99 0-9 70-79 80-89 80-89 30-39 +#> [73] 30-39 80-89 50-59 30-39 0-9 10-19 60-69 20-29 50-59 20-29 80-89 30-39 +#> [85] 20-29 80-89 30-39 40-49 30-39 10-19 30-39 30-39 60-69 90-99 10-19 90-99 +#> [97] 90-99 70-79 60-69 20-29 +#> Levels: 0-9 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 100+
+# Example using a data frame +tibble::tibble(age = sample(1:115, 100, replace = T)) %>% + dplyr::mutate(age_groups = as_age_groups(age, min = 10, max = 100)) +
#> Error in tibble::tibble(age = sample(1:115, 100, replace = T)) %>% dplyr::mutate(age_groups = as_age_groups(age, min = 10, max = 100)): could not find function "%>%"
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/reference/calc_monthly_freq.html b/docs/reference/calc_monthly_freq.html new file mode 100644 index 0000000..48b0d87 --- /dev/null +++ b/docs/reference/calc_monthly_freq.html @@ -0,0 +1,181 @@ + + + + + + + + +Calculate frequencies of groups per month — calc_monthly_freq • nottshcMethods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Calculate frequencies of groups per month

+
+ +
calc_monthly_freq(
+  data,
+  by,
+  date_var_name,
+  .drop_latest_month = TRUE,
+  .calc_year_month_day_vars = TRUE
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
data

Data

by

Grouping variables used in group_by

date_var_name

String specifying date variable, needs to be class date

.drop_latest_month

Logical, specifying whether or not to drop the most recent month

.calc_year_month_day_vars

Logical, specifying whether to calculate separate year, month, and day variable

+ +

Value

+ + + + + +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/reference/ggplotly_nottshc.html b/docs/reference/ggplotly_nottshc.html new file mode 100644 index 0000000..b3fa41f --- /dev/null +++ b/docs/reference/ggplotly_nottshc.html @@ -0,0 +1,184 @@ + + + + + + + + +Convert ggplot object into plotly — ggplotly_nottshc • nottshcMethods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

There are some problems with x and y axis labels when converting +ggplot2 to plotly, especially when using facets. This fun has a workaround that is not perfect.

+
+ +
ggplotly_nottshc(
+  ggplot,
+  xtitle = NULL,
+  ytitle = NULL,
+  aes_txt_tooltip = TRUE,
+  display_mode_bar = FALSE
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
ggplot

ggplot2 object

xtitle

String, x lab title

ytitle

String, y lab title

aes_txt_tooltip

Logical, specifying whether or not to use tooltip

display_mode_bar

Logical, specifying whether to show the annoying +mode bar from plotly, FALSE by default!

+ +

Value

+ + + + + +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/reference/hash.html b/docs/reference/hash.html index 855899f..d325591 100644 --- a/docs/reference/hash.html +++ b/docs/reference/hash.html @@ -72,7 +72,7 @@ nottshcMethods - 0.0.1 + 0.2.0

diff --git a/docs/reference/index.html b/docs/reference/index.html index 90a4c11..0a72747 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ nottshcMethods - 0.0.1 + 0.2.0 @@ -127,12 +127,36 @@

as_age_groups()

+ +

Categorise continuous age into age groups

+ + + +

calc_monthly_freq()

+ +

Calculate frequencies of groups per month

+ + + +

ggplotly_nottshc()

+ +

Convert ggplot object into plotly

+ +

hash()

One way hash a vector

+ +

sample_vector()

+ +

CDU data science team ggplot2 theme

+ +

theme_nottshc()

diff --git a/docs/reference/sample_vector.html b/docs/reference/sample_vector.html new file mode 100644 index 0000000..0bcd506 --- /dev/null +++ b/docs/reference/sample_vector.html @@ -0,0 +1,186 @@ + + + + + + + + +CDU data science team ggplot2 theme — sample_vector • nottshcMethods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

A ggplot2 theme with a white panel background, no grid lines, +large axis and legend titles, +and increased text padding for better readability.

+
+ +
sample_vector(values, weights, length)
+ +

Arguments

+ + + + + + + + + + + + + + +
values

Vector- the thing you want to sample from

weights

vector of integers the same length as values- the proportions +with which you want to sample

length

integer- how long you want the return value to be- e.g. the +number of rows in a dataframe

+ + +

Examples

+
sample_vector(values = c(NA, "Male", "Female", "Other"), +weights = c(10, 50, 50, 2), +length = 100) +
#> [1] "Other" "Male" "Male" "Male" "Female" "Female" "Female" "Female" +#> [9] "Female" "Female" "Female" "Female" "Female" NA "Male" "Male" +#> [17] "Male" "Male" "Male" "Female" "Male" "Male" "Male" "Male" +#> [25] "Female" "Female" "Female" "Male" "Male" "Male" "Male" "Female" +#> [33] "Male" "Male" "Male" "Female" "Male" "Female" "Male" "Male" +#> [41] "Female" "Female" "Male" "Male" "Male" "Female" "Male" "Female" +#> [49] "Female" "Female" "Female" "Male" "Female" "Female" "Female" "Female" +#> [57] "Male" "Female" "Male" "Female" "Female" "Male" "Female" NA +#> [65] NA "Male" "Male" "Other" "Female" NA "Female" "Male" +#> [73] "Female" "Male" "Female" "Male" NA "Female" "Female" "Male" +#> [81] "Female" "Male" "Male" "Male" "Male" "Female" "Male" "Male" +#> [89] "Female" "Male" "Female" "Male" "Male" "Female" NA "Male" +#> [97] NA "Female" "Female" "Male"
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/reference/theme_nottshc.html b/docs/reference/theme_nottshc.html index 2a63ec6..7281240 100644 --- a/docs/reference/theme_nottshc.html +++ b/docs/reference/theme_nottshc.html @@ -74,7 +74,7 @@ nottshcMethods - 0.0.1 + 0.2.0