Skip to content

Commit

Permalink
Merge pull request #8 from CDU-data-science-team/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ChrisBeeley committed Apr 28, 2021
2 parents 70abad9 + b987207 commit ef5c9da
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
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")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
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)
21 changes: 21 additions & 0 deletions R/sample_vector.R
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)
22 changes: 22 additions & 0 deletions man/sample_vector.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef5c9da

Please sign in to comment.