-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from CDU-data-science-team/development
Development
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
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.0.1 | ||
Version: 0.1.0 | ||
Date: 2021-03-29 | ||
Authors@R: c( | ||
person("Milan", "Wiedemann", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1991-282X")), | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(hash) | ||
export(sample_vector) | ||
export(theme_nottshc) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#' CDU data science team ggplot2 theme | ||
#' | ||
#' A ggplot2 theme with a white panel background, no grid lines, | ||
#' large axis and legend titles, | ||
#' and increased text padding for better readability. | ||
#' | ||
#' @param values Vector- the thing you want to sample from | ||
#' @param weights vector of integers the same length as values- the proportions | ||
#' with which you want to sample | ||
#' @param length integer- how long you want the return value to be- e.g. the | ||
#' number of rows in a dataframe | ||
#' | ||
#' @export | ||
sample_vector <- function(values, weights, length){ | ||
|
||
sample(values, length, replace = TRUE, prob = weights / sum(weights)) | ||
} | ||
|
||
sample_vector(values = c(NA, "Male", "Female", "Other"), | ||
weights = c(10, 50, 50, 2), | ||
length = 100) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.