Details
- Standard error of a proportion is calculated using the formula:
-$$SE = \sqrt{\frac{p(1 - p)}{n}}$$
+ Standard error of a proportion is calculated using the formula:
+$$SE = \sqrt{\frac{p(1 - p)}{n}}$$
This formula assumes that the binomial sampling distribution underlying the
observed proportion can be approximated by a normal distribution. This
assumption is valid when the proportion variance (np(1 - p)) is
diff --git a/search.json b/search.json
index 4753a23..c905be8 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://ccsarapas.github.io/lighthouse/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2021 lighthouse authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Casey Sarapas. Author, maintainer.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sarapas C (2024). lighthouse: Utility Functions Lighthouse Institute Projects. R package version 0.7.0, https://ccsarapas.github.io/lighthouse/, https://github.com/ccsarapas/lighthouse.","code":"@Manual{, title = {lighthouse: Utility Functions for Lighthouse Institute Projects}, author = {Casey Sarapas}, year = {2024}, note = {R package version 0.7.0, https://ccsarapas.github.io/lighthouse/}, url = {https://github.com/ccsarapas/lighthouse}, }"},{"path":"https://ccsarapas.github.io/lighthouse/index.html","id":"lighthouse","dir":"","previous_headings":"","what":"Utility Functions for Lighthouse Institute Projects","title":"Utility Functions for Lighthouse Institute Projects","text":"lighthouse package includes various utility functions used staff Lighthouse Institute, division Chestnut Health Systems.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Utility Functions for Lighthouse Institute Projects","text":"Install lighthouse package running:","code":"remotes::install_github(\"ccsarapas/lighthouse\")"},{"path":"https://ccsarapas.github.io/lighthouse/reference/accuracy_stats.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute common accuracy and agreement metrics — accuracy_stats","title":"Compute common accuracy and agreement metrics — accuracy_stats","text":"Given vector true_values one vectors test values (passed ...), computes sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), Cohen's kappa.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/accuracy_stats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute common accuracy and agreement metrics — accuracy_stats","text":"","code":"accuracy_stats(.data, true_values, ..., include_counts = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/accuracy_stats.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute common accuracy and agreement metrics — accuracy_stats","text":"","code":"# create example data w predictors with different properties: ex_data <- tibble::tibble( actual = rbinom(250, 1, .3), # 250 cases, p(outcome) = .3 prediction1 = ifelse(runif(250) <= .05, 1L - actual, actual), # 5% error rate prediction2 = ifelse(runif(250) <= .15, 1L - actual, actual), # 15% error rate prediction3 = ifelse(runif(250) <= .35, 1L - actual, actual), # 35% error rate prediction4 = ifelse(runif(250) <= .15, 1L, actual), # 15% with positive bias prediction5 = ifelse(runif(250) <= .15, 0L, actual) # 15% with negative bias ) # testing predicted v actual values ex_data %>% accuracy_stats(actual, prediction1) #> # A tibble: 1 × 7 #> Predictor n Kappa Sensitivity Specificity PPV NPV #> #> 1 prediction1 250 0.845 0.901 0.947 0.890 0.952 # can test multiple predictors simultaneously ex_data %>% accuracy_stats(actual, prediction1:prediction5) #> # A tibble: 5 × 7 #> Predictor n Kappa Sensitivity Specificity PPV NPV #> #> 1 prediction1 250 0.845 0.901 0.947 0.890 0.952 #> 2 prediction2 250 0.628 0.840 0.822 0.694 0.914 #> 3 prediction3 250 0.213 0.593 0.639 0.440 0.766 #> 4 prediction4 250 0.828 1 0.882 0.802 1 #> 5 prediction5 250 0.846 0.802 1 1 0.914 # if `include_counts` = TRUE, will also return n of false positives, # false negatives, etc., as well as and observed and expected % agreement ex_data %>% accuracy_stats(actual, prediction1:prediction5, include_counts = TRUE) #> # A tibble: 5 × 13 #> Predictor n TP FP TN FN pAgreeObserved pAgreeExpected Kappa #> #> 1 prediction1 250 73 9 160 8 0.932 0.561 0.845 #> 2 prediction2 250 68 30 139 13 0.828 0.538 0.628 #> 3 prediction3 250 48 61 108 33 0.624 0.523 0.213 #> 4 prediction4 250 81 20 149 0 0.92 0.534 0.828 #> 5 prediction5 250 65 0 169 16 0.936 0.584 0.846 #> # ℹ 4 more variables: Sensitivity , Specificity , PPV , #> # NPV "},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_crossings.html","id":null,"dir":"Reference","previous_headings":"","what":"Add crossings to a dataframe for area charts — add_crossings","title":"Add crossings to a dataframe for area charts — add_crossings","text":"Augments dataframe x-values y = f(x) = 0. useful creating area charts different fills values less versus greater 0.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_crossings.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add crossings to a dataframe for area charts — add_crossings","text":"","code":"add_crossings(data, x, y, .by = NULL)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_crossings.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add crossings to a dataframe for area charts — add_crossings","text":"data data frame containing original x y values. x x-axis values. y y-axis values. .Grouping variable(s). Useful computing crossings faceted plots.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_crossings.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add crossings to a dataframe for area charts — add_crossings","text":"input data frame additional rows representing crossings (y = 0), two new columns: pos_neg: Indicates whether y-value positive (\"pos\") negative (\"neg\"). cross_grp: grouping variable segments crossings.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_crossings.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add crossings to a dataframe for area charts — add_crossings","text":"returned dataframe include columns pos_neg cross_group. Within geom_area(), cross_group mapped group, pos_neg mapped aesthetics fill color.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_crossings.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add crossings to a dataframe for area charts — add_crossings","text":"","code":"nile_flow <- tibble::tibble( Year = time(Nile), Flow = as.numeric(Nile), FlowDelta = (Flow - Flow[[1]]) / Flow[[1]] ) nile_flow_x0 <- add_crossings(nile_flow, Year, FlowDelta) ggplot2::ggplot(nile_flow_x0, ggplot2::aes(Year, FlowDelta)) + ggplot2::geom_area( ggplot2::aes(group = cross_grp, color = pos_neg, fill = pos_neg), alpha = 0.25, show.legend = FALSE ) + ggplot2::geom_hline(yintercept = 0, linewidth = 0.25) + ggplot2::scale_color_manual( values = c(\"darkred\", \"blue\"), aesthetics = c(\"color\", \"fill\") ) + ggplot2::scale_y_continuous( \"Nile River Annual Flow:\\n% Change from 1871\", labels = scales::percent ) + ggplot2::theme_minimal()"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_empty_rows.html","id":null,"dir":"Reference","previous_headings":"","what":"Add empty rows — add_empty_rows","title":"Add empty rows — add_empty_rows","text":"Adds number empty rows passed .nrows (default 1) positions passed ... Vectorized ., ., .nrows.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_empty_rows.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add empty rows — add_empty_rows","text":"","code":"add_empty_rows(.data, .before = NULL, .after = NULL, .nrows = 1)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_header.html","id":null,"dir":"Reference","previous_headings":"","what":"Add header rows to a table — add_header","title":"Add header rows to a table — add_header","text":"Inserts header rows using unique values .","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_header.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add header rows to a table — add_header","text":"","code":"add_header( data, from, to, skip_single_row = FALSE, indent = \"\", drop_from = TRUE )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_header.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add header rows to a table — add_header","text":"","code":"dplyr::starwars %>% head(13) %>% dplyr::arrange(species) %>% add_header(from = species, to = name, indent = \" \") #> # A tibble: 16 × 13 #> name height mass hair_color skin_color eye_color birth_year sex gender #> #> 1 \"Droid\" NA NA NA NA NA NA NA NA #> 2 \" C-3P… 167 75 NA gold yellow 112 none mascu… #> 3 \" R2-D… 96 32 NA white, bl… red 33 none mascu… #> 4 \" R5-D… 97 32 NA white, red red NA none mascu… #> 5 \"Human\" NA NA NA NA NA NA NA NA #> 6 \" Luke… 172 77 blond fair blue 19 male mascu… #> 7 \" Dart… 202 136 none white yellow 41.9 male mascu… #> 8 \" Leia… 150 49 brown light brown 19 fema… femin… #> 9 \" Owen… 178 120 brown, gr… light blue 52 male mascu… #> 10 \" Beru… 165 75 brown light blue 47 fema… femin… #> 11 \" Bigg… 183 84 black light brown 24 male mascu… #> 12 \" Obi-… 182 77 auburn, w… fair blue-gray 57 male mascu… #> 13 \" Anak… 188 84 blond fair blue 41.9 male mascu… #> 14 \" Wilh… 180 NA auburn, g… fair blue 64 male mascu… #> 15 \"Wookie… NA NA NA NA NA NA NA NA #> 16 \" Chew… 228 112 brown unknown blue 200 male mascu… #> # ℹ 4 more variables: homeworld , films , vehicles , #> # starships "},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_plot_slide.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a plot to a PowerPoint slide — add_plot_slide","title":"Add a plot to a PowerPoint slide — add_plot_slide","text":"function adds new slide PowerPoint presentation plot centered beneath title, scaled large possible within specified margins preserving aspect ratio.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_plot_slide.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a plot to a PowerPoint slide — add_plot_slide","text":"","code":"add_plot_slide( pptx, title = NULL, plot = ggplot2::last_plot(), w = 7, h = 4, bg = \"white\", w_margin = 0.15, h_margin = 0.15, layout = \"Title and Content\", ... )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_plot_slide.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a plot to a PowerPoint slide — add_plot_slide","text":"pptx object class rpptx, created officer::read_pptx() title optional slide title plot plot add. Default last plot created. w plot width inches h plot height inches bg background color plot area w_margin horizontal margin inches h_margin vertical margin inches layout slide layout use ... additional arguments passed officer::ph_with()","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_plot_slide.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a plot to a PowerPoint slide — add_plot_slide","text":"updated rpptx object","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_plot_slide.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a plot to a PowerPoint slide — add_plot_slide","text":"","code":"if (FALSE) { # \\dontrun{ library(ggplot2) library(officer) plot <- ggplot(mtcars, aes(mpg, wt)) + geom_point() pptx <- read_pptx() pptx <- pptx |> add_plot_slide(\"Larger Elements\", plot, w = 5, h = 3.5) |> add_plot_slide(\"Smaller Elements\", plot, w = 10, h = 7) |> add_plot_slide(\"Wider\", plot, w = 9, h = 3) |> add_plot_slide(\"Taller\", plot, w = 4, h = 6) path <- paste0(tempfile(), \".pptx\") print(pptx, target = path) file.open(path) invisible(file.remove(path)) } # }"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_rows_at_value.html","id":null,"dir":"Reference","previous_headings":"","what":"Add empty rows at specified values in a column — add_rows_at_value","title":"Add empty rows at specified values in a column — add_rows_at_value","text":"Adds empty row(s) based specified value(s) col. default, insert one empty row last occurrence col value passed vals.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_rows_at_value.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add empty rows at specified values in a column — add_rows_at_value","text":"","code":"add_rows_at_value( .data, col, vals, where = c(\"after_last\", \"before_first\", \"after_each\", \"before_each\"), no_match = c(\"error\", \"warn\", \"ignore\"), nrows = 1, ... )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_rows_at_value.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add empty rows at specified values in a column — add_rows_at_value","text":".data data frame data frame extension. col column search values. vals character vector value(s) search col. insert rows relative values vals. nrows number empty rows insert location. ... dots included support error-checking must empty. nomatch value vals appear col.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_rows_at_value.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add empty rows at specified values in a column — add_rows_at_value","text":"updated version .data new empty rows inserted.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_rows_at_value.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add empty rows at specified values in a column — add_rows_at_value","text":"pre-release version function, used lighthouse code, values search passed ... unquoted symbols. Values must now now instead passed vals character vector. arguments ..nrows also renamed nrows. function attempt detect give informative warning called \"old\" parameters (e.g., deprecated argument list symbols rather character vector). Also see syms_to_chr(), provided utility adapting old code.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/add_rows_at_value.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add empty rows at specified values in a column — add_rows_at_value","text":"","code":"set.seed(13) ex_data <- tibble::tibble( category = sort(sample(LETTERS[1:3], 10, replace = TRUE)), var = round(runif(10), 2) ) add_rows_at_value(ex_data, category, c(\"A\", \"B\")) #> # A tibble: 12 × 2 #> category var #> #> 1 A 0.87 #> 2 A 0.68 #> 3 A 0.14 #> 4 A 0.55 #> 5 NA NA #> 6 B 0.68 #> 7 B 0.53 #> 8 B 0.09 #> 9 B 0.62 #> 10 NA NA #> 11 C 0.03 #> 12 C 0.46 add_rows_at_value(ex_data, category, c(\"A\", \"C\"), where = \"after_each\") #> # A tibble: 16 × 2 #> category var #> #> 1 A 0.87 #> 2 NA NA #> 3 A 0.68 #> 4 NA NA #> 5 A 0.14 #> 6 NA NA #> 7 A 0.55 #> 8 NA NA #> 9 B 0.68 #> 10 B 0.53 #> 11 B 0.09 #> 12 B 0.62 #> 13 C 0.03 #> 14 NA NA #> 15 C 0.46 #> 16 NA NA add_rows_at_value( ex_data, category, unique(ex_data$category), where = \"before_first\", nrows = 2 ) #> # A tibble: 16 × 2 #> category var #> #> 1 NA NA #> 2 NA NA #> 3 A 0.87 #> 4 A 0.68 #> 5 A 0.14 #> 6 A 0.55 #> 7 NA NA #> 8 NA NA #> 9 B 0.68 #> 10 B 0.53 #> 11 B 0.09 #> 12 B 0.62 #> 13 NA NA #> 14 NA NA #> 15 C 0.03 #> 16 C 0.46"},{"path":"https://ccsarapas.github.io/lighthouse/reference/aggregate_if_any.html","id":null,"dir":"Reference","previous_headings":"","what":"Sum, maxima and minima with alternative missing value handling — aggregate_if_any","title":"Sum, maxima and minima with alternative missing value handling — aggregate_if_any","text":"Returns sum, maximum, minimum input values, similar base::sum(), min(), max(). Unlike base functions, variants return NA values NA na.rm = TRUE. (base::sum(), min(), max() return 0, -Inf, Inf, respectively, situation). Also unlike base functions, na.rm TRUE default (since typical use case).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/aggregate_if_any.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sum, maxima and minima with alternative missing value handling — aggregate_if_any","text":"","code":"sum_if_any(..., na.rm = TRUE) max_if_any(..., na.rm = TRUE) min_if_any(..., na.rm = TRUE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/aggregate_if_any.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sum, maxima and minima with alternative missing value handling — aggregate_if_any","text":"... numeric, logical, (max_if_any() min_if_any()) character vectors. na.rm logical. missing values (including NaN) removed?","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/aggregate_if_any.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sum, maxima and minima with alternative missing value handling — aggregate_if_any","text":"","code":"some_na <- c(1, 2, NA) all_na <- c(NA, NA, NA) # unlike base functions, `na.rm = TRUE` by default max(some_na) #> [1] NA max_if_any(some_na) #> [1] 2 # unlike base functions, returns 0 when `na.rm = TRUE` and all inputs are `NA` sum(all_na, na.rm = TRUE) #> [1] 0 sum_if_any(all_na) #> [1] NA"},{"path":"https://ccsarapas.github.io/lighthouse/reference/any-all-in.html","id":null,"dir":"Reference","previous_headings":"","what":"Test whether multiple values are in a vector — any-all-in","title":"Test whether multiple values are in a vector — any-all-in","text":"infix operators test whether left-hand side elements occur right-hand side.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/any-all-in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test whether multiple values are in a vector — any-all-in","text":"","code":"lhs %all_in% rhs lhs %any_in% rhs"},{"path":"https://ccsarapas.github.io/lighthouse/reference/any-all-in.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Test whether multiple values are in a vector — any-all-in","text":"%all_in% returns TRUE elements left operand (lhs) found right operand (rhs). Equivalent (lhs %% rhs). %any_in% returns TRUE elements left operand (lhs) found right operand (rhs). Equivalent (lhs %% rhs).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/any-all-in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Test whether multiple values are in a vector — any-all-in","text":"","code":"maybe_states <- c(\"Idaho\", \"Illinois\", \"North Tuba\", \"Maine\") maybe_states %any_in% state.name # TRUE #> [1] TRUE maybe_states %all_in% state.name # FALSE #> [1] FALSE rm(maybe_states)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/asterisks.html","id":null,"dir":"Reference","previous_headings":"","what":"Return asterisks corresponding to p-values — asterisks","title":"Return asterisks corresponding to p-values — asterisks","text":"Returns asterisks indicating significance levels vector p values.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/asterisks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return asterisks corresponding to p-values — asterisks","text":"","code":"asterisks( p, trends = TRUE, levels = c(0.1, 0.05, 0.01, 0.001), marks = c(sig = \"*\", trend = \"+\", ns = NA_character_), include_key = FALSE )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/asterisks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return asterisks corresponding to p-values — asterisks","text":"p numeric vector p-values. trends logical. trends (e.g., .05 < p < .10) marked? levels numeric vector demarcating ranges p values receive unique significance marks. marks named character vector specifying marks significance, trend, non-significance. include_key logical. key significance marks included attribute?","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/asterisks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return asterisks corresponding to p-values — asterisks","text":"character vector asterisks corresponding p-values. include_key = TRUE, vector 'key' attribute indicating significance levels.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/asterisks.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return asterisks corresponding to p-values — asterisks","text":"","code":"p <- c(0.5, 0.09, 0.03, 0.008, 0.0003) tibble::tibble(p, sig = asterisks(p)) #> # A tibble: 5 × 2 #> p sig #> #> 1 0.5 NA #> 2 0.09 + #> 3 0.03 * #> 4 0.008 ** #> 5 0.0003 *** tibble::tibble(p, sig = asterisks(p, trends = FALSE)) #> # A tibble: 5 × 2 #> p sig #> #> 1 0.5 NA #> 2 0.09 NA #> 3 0.03 * #> 4 0.008 ** #> 5 0.0003 *** tibble::tibble(p, sig = asterisks(p, trends = FALSE, marks = c(ns = \"ns\"))) #> # A tibble: 5 × 2 #> p sig #> #> 1 0.5 ns #> 2 0.09 ns #> 3 0.03 * #> 4 0.008 ** #> 5 0.0003 *** asterisks(p, include_key = TRUE) #> [1] + * ** *** #> attr(,\"key\") #> *** ** * + #> 0.001 0.010 0.050 0.100 #> Levels: *** ** * +"},{"path":"https://ccsarapas.github.io/lighthouse/reference/bizday.html","id":null,"dir":"Reference","previous_headings":"","what":"Find the nth or next business day — bizday","title":"Find the nth or next business day — bizday","text":"nth_bizday() returns nth business day given date, based CHS, Illinois, federal holidays. next_bizday() wrapper ","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/bizday.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find the nth or next business day — bizday","text":"","code":"nth_bizday( x, n, include_today = FALSE, holidays = c(\"Chestnut\", \"Illinois\", \"federal\") ) next_bizday( x, include_today = FALSE, holidays = c(\"Chestnut\", \"Illinois\", \"federal\") )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/bizday.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Find the nth or next business day — bizday","text":"x date vector dates. n integer indicating ow many business days forward find. include_today logical indicating whether x counted one day (assuming business day)? holidays character indicating set holidays use.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/bizday.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Find the nth or next business day — bizday","text":"nth_bizday returns nth business day provided date(s). next_bizday returns next business day provided date(s).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/bizday.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Find the nth or next business day — bizday","text":"","code":"next_bizday(as.Date(\"2024-07-02\")) #> [1] \"2024-07-03\" nth_bizday(as.Date(\"2024-07-02\"), 5) #> [1] \"2024-07-10\" nth_bizday(as.Date(\"2024-07-02\"), 5, include_today = TRUE) #> [1] \"2024-07-09\""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cascade.html","id":null,"dir":"Reference","previous_headings":"","what":"Utilities for service cascades — cascade","title":"Utilities for service cascades — cascade","text":"Functions working service cascades.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cascade.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utilities for service cascades — cascade","text":"","code":"cascade_fill_bwd(data, vars) cascade_fill_fwd(data, vars, fill = c(\"NA\", \"FALSE\")) cascade_summarize(data, vars)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/ci_sig.html","id":null,"dir":"Reference","previous_headings":"","what":"Test whether a confidence interval excludes a given value — ci_sig","title":"Test whether a confidence interval excludes a given value — ci_sig","text":"Tests whether confidence interval excldes specified reference value. generally null value relevant test, excluding value indicates test statistically significant.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/ci_sig.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test whether a confidence interval excludes a given value — ci_sig","text":"","code":"ci_sig( ll, ul, reference = 1, return = c(\"logical\", \"asterisks\"), marks = c(\"*\", NA_character_) )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/ci_sig.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Test whether a confidence interval excludes a given value — ci_sig","text":"ll numeric vector containing confidence interval lower limits. ul numeric vector containing corresponding upper limits. reference value check . generally null value relevant test (e.g., 1 odds ratios, 0 beta coefficients). return \"logical\", return logical vector indicating whether confidence interval excludes reference. asterisks, return character vector, using characters passed marks. marks length-2 vector specifying strings mark significant non-significant results return = \"asterisks\".","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/ci_sig.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Test whether a confidence interval excludes a given value — ci_sig","text":"return = \\\"logical\\\" (default), logical vector. return = \\\"asterisks\\\", character vector.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/ci_sig.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Test whether a confidence interval excludes a given value — ci_sig","text":"","code":"beta_CIs <- glm( Survived ~ Sex * Age, family = binomial, weights = Freq, data = as.data.frame(Titanic) ) %>% confint() #> Waiting for profiling to be done... OR_CIs <- tibble::as_tibble(exp(beta_CIs), rownames = \"term\") beta_CIs <- tibble::as_tibble(beta_CIs, rownames = \"term\") beta_CIs %>% dplyr::mutate(sig = ci_sig(`2.5 %`, `97.5 %`)) #> # A tibble: 4 × 4 #> term `2.5 %` `97.5 %` sig #> #> 1 (Intercept) -0.687 0.303 TRUE #> 2 SexFemale -0.0834 1.48 FALSE #> 3 AgeAdult -1.69 -0.669 TRUE #> 4 SexFemale:AgeAdult 0.918 2.56 FALSE beta_CIs %>% dplyr::mutate(sig = ci_sig(`2.5 %`, `97.5 %`, return = \"asterisks\")) #> # A tibble: 4 × 4 #> term `2.5 %` `97.5 %` sig #> #> 1 (Intercept) -0.687 0.303 * #> 2 SexFemale -0.0834 1.48 NA #> 3 AgeAdult -1.69 -0.669 * #> 4 SexFemale:AgeAdult 0.918 2.56 NA beta_CIs %>% dplyr::mutate(sig = ci_sig(`2.5 %`, `97.5 %`, return = \"asterisks\", marks = c(\"*\", \"ns\"))) #> # A tibble: 4 × 4 #> term `2.5 %` `97.5 %` sig #> #> 1 (Intercept) -0.687 0.303 * #> 2 SexFemale -0.0834 1.48 ns #> 3 AgeAdult -1.69 -0.669 * #> 4 SexFemale:AgeAdult 0.918 2.56 ns OR_CIs %>% dplyr::mutate(sig = ci_sig(`2.5 %`, `97.5 %`, reference = 1, return = \"asterisks\")) #> # A tibble: 4 × 4 #> term `2.5 %` `97.5 %` sig #> #> 1 (Intercept) 0.503 1.35 NA #> 2 SexFemale 0.920 4.39 NA #> 3 AgeAdult 0.185 0.512 * #> 4 SexFemale:AgeAdult 2.50 12.9 *"},{"path":"https://ccsarapas.github.io/lighthouse/reference/cohen_w.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute Cohen's w — cohen_w","title":"Compute Cohen's w — cohen_w","text":"Cohen's w effect size measure associations nominal variables, generally used conjunction chi-squared tests. cohen_w() computes Cohen's w results chi-squared test.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cohen_w.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute Cohen's w — cohen_w","text":"","code":"cohen_w(chisq)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/cohen_w.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute Cohen's w — cohen_w","text":"chisq \"htest\" object returned stats::chisq.test().","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cohen_w.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute Cohen's w — cohen_w","text":"","code":"chisq_out <- chisq.test(ggplot2::diamonds$cut, ggplot2::diamonds$color) cohen_w(chisq_out) #> [1] 0.07584867"},{"path":"https://ccsarapas.github.io/lighthouse/reference/cols_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get information about data frame columns — cols_info","title":"Get information about data frame columns — cols_info","text":"Returns summary column's class, type, missing data. data frame imported SPSS .sav file \\\"labelled\\\" package installed, SPSS variable labels also included.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cols_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get information about data frame columns — cols_info","text":"","code":"cols_info(x, zap_spss = TRUE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/cols_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get information about data frame columns — cols_info","text":"x data frame. zap_spss TRUE (default) \\\"labelled\\\" package available, convert SPSS-style labeled columns standard R columns. Ignored \\\"labelled\\\" installed.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cols_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get information about data frame columns — cols_info","text":"tibble row column x, containing: column: Column name class: Column class type: Column type valid_n: Number non-missing values valid_pct: Percentage non-missing values label: SPSS variable label (applicable)","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cols_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get information about data frame columns — cols_info","text":"","code":"cols_info(dplyr::starwars) #> # A tibble: 14 × 5 #> column class type valid_n valid_pct #> #> 1 name character character 87 1 #> 2 height integer integer 81 0.931 #> 3 mass numeric double 59 0.678 #> 4 hair_color character character 82 0.943 #> 5 skin_color character character 87 1 #> 6 eye_color character character 87 1 #> 7 birth_year numeric double 43 0.494 #> 8 sex character character 83 0.954 #> 9 gender character character 83 0.954 #> 10 homeworld character character 77 0.885 #> 11 species character character 83 0.954 #> 12 films list list 87 1 #> 13 vehicles list list 87 1 #> 14 starships list list 87 1"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_duplicates.html","id":null,"dir":"Reference","previous_headings":"","what":"Count duplicates across specified columns — count_duplicates","title":"Count duplicates across specified columns — count_duplicates","text":"variant dplyr::count() returns number duplicate observations across specified columns. Returns number unique duplicated values, well total number duplicated observations.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_duplicates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count duplicates across specified columns — count_duplicates","text":"","code":"count_duplicates(.data, ..., na.rm = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_duplicates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count duplicates across specified columns — count_duplicates","text":".data data frame. ... Columns use duplicate checks. empty, columns used. na.rm TRUE, rows containing NA specified columns removed counting duplicates.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_duplicates.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count duplicates across specified columns — count_duplicates","text":"data frame columns: instances: number times unique value duplicated n_unique: number unique values duplicated instances times n_total: total number observations duplicated instances times","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_duplicates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count duplicates across specified columns — count_duplicates","text":"","code":"df <- tibble::tibble( x = c(1, 1, 2, 3, 3), y = c('a', 'a', 'b', 'c', 'c') ) count_duplicates(df) #> # A tibble: 1 × 3 #> instances n_unique n_total #> #> 1 5 1 5 count_duplicates(df, x) #> # A tibble: 2 × 3 #> instances n_unique n_total #> #> 1 1 1 1 #> 2 2 2 4 count_duplicates(df, y) #> # A tibble: 2 × 3 #> instances n_unique n_total #> #> 1 1 1 1 #> 2 2 2 4"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_multiple.html","id":null,"dir":"Reference","previous_headings":"","what":"Count observations for multiple variables — count_multiple","title":"Count observations for multiple variables — count_multiple","text":"variant dplyr::count() returns frequencies (optionally) proportions column passed ....","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_multiple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count observations for multiple variables — count_multiple","text":"","code":"count_multiple( .data, ..., .pct = TRUE, wt = NULL, sort = FALSE, name = NULL, na.rm = FALSE, .by = NULL, .drop = TRUE )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_multiple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count observations for multiple variables — count_multiple","text":".data data frame. ... Columns count frequencies . Can named expressions. .pct TRUE (default), include percentages. sort TRUE, sort output frequency. name Name frequency column. Default \\\"n\\\". na.rm TRUE, remove rows NA values. .selection columns group just operation, functioning alternative dplyr::group_by(). Percentages computed within group rather grand total. See examples. .drop TRUE (default), drop unused factor levels.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_multiple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count observations for multiple variables — count_multiple","text":"data frame columns: grouping variables input data specified .. Variable: name column counted. Value: unique values counted column. n: frequency unique value. pct: (.pct = TRUE) percentage count represents within variable.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_multiple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count observations for multiple variables — count_multiple","text":"","code":"iris %>% count_multiple(Species, Sepal.Length > 5) #> # A tibble: 5 × 4 #> Variable Value n pct #> #> 1 Species setosa 50 0.333 #> 2 Species versicolor 50 0.333 #> 3 Species virginica 50 0.333 #> 4 Sepal.Length > 5 FALSE 32 0.213 #> 5 Sepal.Length > 5 TRUE 118 0.787 ## note effects of grouping # no grouping ggplot2::mpg %>% count_multiple(year, drv, cyl) #> # A tibble: 9 × 4 #> Variable Value n pct #> #> 1 year 1999 117 0.5 #> 2 year 2008 117 0.5 #> 3 drv 4 103 0.440 #> 4 drv f 106 0.453 #> 5 drv r 25 0.107 #> 6 cyl 4 81 0.346 #> 7 cyl 5 4 0.0171 #> 8 cyl 6 79 0.338 #> 9 cyl 8 70 0.299 # grouping w `group_by()`: counts and % nested within groups, output is grouped ggplot2::mpg %>% dplyr::group_by(year) %>% count_multiple(drv, cyl) #> # A tibble: 13 × 5 #> # Groups: year [2] #> year Variable Value n pct #> #> 1 1999 drv 4 49 0.419 #> 2 1999 drv f 57 0.487 #> 3 1999 drv r 11 0.0940 #> 4 2008 drv 4 54 0.462 #> 5 2008 drv f 49 0.419 #> 6 2008 drv r 14 0.120 #> 7 1999 cyl 4 45 0.385 #> 8 1999 cyl 6 45 0.385 #> 9 1999 cyl 8 27 0.231 #> 10 2008 cyl 4 36 0.308 #> 11 2008 cyl 5 4 0.0342 #> 12 2008 cyl 6 34 0.291 #> 13 2008 cyl 8 43 0.368 # grouping w `.by`: counts and % nested within groups, output isn't grouped ggplot2::mpg %>% count_multiple(drv, cyl, .by = year) #> # A tibble: 13 × 5 #> year Variable Value n pct #> #> 1 1999 drv 4 49 0.419 #> 2 1999 drv f 57 0.487 #> 3 1999 drv r 11 0.0940 #> 4 2008 drv 4 54 0.462 #> 5 2008 drv f 49 0.419 #> 6 2008 drv r 14 0.120 #> 7 1999 cyl 4 45 0.385 #> 8 1999 cyl 6 45 0.385 #> 9 1999 cyl 8 27 0.231 #> 10 2008 cyl 4 36 0.308 #> 11 2008 cyl 5 4 0.0342 #> 12 2008 cyl 6 34 0.291 #> 13 2008 cyl 8 43 0.368"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Count NA values by group — count_na","title":"Count NA values by group — count_na","text":"Returns patterns missingness across one variables, number cases pattern.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count NA values by group — count_na","text":"","code":"count_na( .data, ..., .label_missing = NA_character_, .label_valid = \"OK\", .add_percent = FALSE )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_pct.html","id":null,"dir":"Reference","previous_headings":"","what":"Count observations with percentage — count_pct","title":"Count observations with percentage — count_pct","text":"variant dplyr::count() includes column showing percentage total observations group.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_pct.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count observations with percentage — count_pct","text":"","code":"count_pct( .data, ..., na.rm = FALSE, .by = NULL, wt = NULL, sort = FALSE, .drop = dplyr::group_by_drop_default() )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_pct.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count observations with percentage — count_pct","text":"... Variables group . passed dplyr::count(). na.rm TRUE, removes rows NA values calculations. .selection columns group just operation, functioning alternative dplyr::group_by(). Percentages computed within group rather grand total. See examples. wt Frequency weights. Can NULL variable: NULL (default), counts number rows group. variable, computes sum(wt) group. sort TRUE, show largest groups top. .drop Handling factor levels appear data, passed group_by(). count(): FALSE include counts empty groups (.e. levels factors exist data). add_count(): deprecated since actually affect output.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_pct.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count observations with percentage — count_pct","text":"data frame columns grouping variables, n (count observations group), pct (percentage total observations group).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_pct.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Count observations with percentage — count_pct","text":"Percentages within subgroups can obtained grouping group_by","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_pct.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count observations with percentage — count_pct","text":"","code":"library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union ## note effect of `na.rm` on percentages dplyr::starwars %>% count_pct(gender) #> # A tibble: 3 × 3 #> gender n pct #> #> 1 feminine 17 0.195 #> 2 masculine 66 0.759 #> 3 NA 4 0.0460 dplyr::starwars %>% count_pct(gender, na.rm = TRUE) #> # A tibble: 2 × 3 #> gender n pct #> #> 1 feminine 17 0.205 #> 2 masculine 66 0.795 ## note effect of grouping on percentages # no grouping: % of grand total ggplot2::mpg %>% count_pct(year, cyl) #> # A tibble: 7 × 4 #> year cyl n pct #> #> 1 1999 4 45 0.192 #> 2 1999 6 45 0.192 #> 3 1999 8 27 0.115 #> 4 2008 4 36 0.154 #> 5 2008 5 4 0.0171 #> 6 2008 6 34 0.145 #> 7 2008 8 43 0.184 # grouping w `group_by()`: % of group, output is grouped ggplot2::mpg %>% dplyr::group_by(year) %>% count_pct(cyl) #> # A tibble: 7 × 4 #> # Groups: year [2] #> year cyl n pct #> #> 1 1999 4 45 0.385 #> 2 1999 6 45 0.385 #> 3 1999 8 27 0.231 #> 4 2008 4 36 0.308 #> 5 2008 5 4 0.0342 #> 6 2008 6 34 0.291 #> 7 2008 8 43 0.368 # grouping w `.by`: % of group, output isn't grouped ggplot2::mpg %>% count_pct(cyl, .by = year) #> # A tibble: 7 × 4 #> year cyl n pct #> #> 1 1999 4 45 0.385 #> 2 1999 6 45 0.385 #> 3 1999 8 27 0.231 #> 4 2008 4 36 0.308 #> 5 2008 5 4 0.0342 #> 6 2008 6 34 0.291 #> 7 2008 8 43 0.368"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_unique.html","id":null,"dir":"Reference","previous_headings":"","what":"Count unique values in data frame columns — count_unique","title":"Count unique values in data frame columns — count_unique","text":"variant dplyr::count() returns number unique values across set columns data frame.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_unique.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count unique values in data frame columns — count_unique","text":"","code":"count_unique(.data, ..., name = \"n_unique\", na.rm = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_unique.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count unique values in data frame columns — count_unique","text":".data data frame. ... columns count unique values across. name name give unique count column. na.rm exclude NAs counts?","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_unique.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count unique values in data frame columns — count_unique","text":"","code":"mtcars %>% count_unique(cyl, gear) #> n_unique #> 1 8 mtcars %>% count_unique(cyl, gear, carb, name = \"unique_combos\") #> unique_combos #> 1 12"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_with_total.html","id":null,"dir":"Reference","previous_headings":"","what":"Count observations with totals row — count_with_total","title":"Count observations with totals row — count_with_total","text":"variant dplyr::count() adds row column totals. Totals computed first column passed ... unless otherwise specified totals_for.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_with_total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count observations with totals row — count_with_total","text":"","code":"count_with_total( .data, ..., totals_for = NULL, label = \"Total\", first_row = FALSE, wt = NULL, sort = FALSE, name = NULL, .drop = dplyr::group_by_drop_default() )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_with_total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count observations with totals row — count_with_total","text":"... Variables group . totals_for variable total . omitted, defaults first variable .... label label totals row. Defaults \"Total\". first_row TRUE, totals row placed first output. FALSE (default), placed last. wt Frequency weights. Can NULL variable: NULL (default), counts number rows group. variable, computes sum(wt) group. sort TRUE, show largest groups top. name name new column output. omitted, default n. already column called n, use nn. column called n nn, 'll use nnn, , adding ns gets new name. .drop Handling factor levels appear data, passed dplyr::group_by(). FALSE include counts empty groups (.e. levels factors exist data).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_with_total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count observations with totals row — count_with_total","text":"data frame counts grouping level, along \"totals\" row column totals totaled variable.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/count_with_total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count observations with totals row — count_with_total","text":"","code":"mtcars %>% count_with_total(cyl) #> cyl n #> 1 4 11 #> 2 6 7 #> 3 8 14 #> 4 Total 32 mtcars %>% count_with_total(cyl, gear) #> cyl gear n #> 1 4 3 1 #> 2 4 4 8 #> 3 4 5 2 #> 4 6 3 2 #> 5 6 4 4 #> 6 6 5 1 #> 7 8 3 12 #> 8 8 5 2 #> 9 Total 3 15 #> 10 Total 4 12 #> 11 Total 5 5 mtcars %>% count_with_total(cyl, gear, totals_for = gear) #> cyl gear n #> 1 4 3 1 #> 2 4 4 8 #> 3 4 5 2 #> 4 4 Total 11 #> 5 6 3 2 #> 6 6 4 4 #> 7 6 5 1 #> 8 6 Total 7 #> 9 8 3 12 #> 10 8 5 2 #> 11 8 Total 14"},{"path":"https://ccsarapas.github.io/lighthouse/reference/crosstab.html","id":null,"dir":"Reference","previous_headings":"","what":"Cross-tabulate observations — crosstab","title":"Cross-tabulate observations — crosstab","text":"Builds contingency table similar base::table(). Unlike base::table(), crosstab() pipe-friendly, outputs ordinary tibble / data.frame – e.g., retain structure exported csv. Currently supports two variables.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/crosstab.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cross-tabulate observations — crosstab","text":"","code":"crosstab(.data, ..., .drop = TRUE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/cumsum_desc.html","id":null,"dir":"Reference","previous_headings":"","what":"Descending cumulative sum — cumsum_desc","title":"Descending cumulative sum — cumsum_desc","text":"Returns cumulative sum beginning last element x.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/cumsum_desc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Descending cumulative sum — cumsum_desc","text":"","code":"cumsum_desc(x)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/cumsum_desc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Descending cumulative sum — cumsum_desc","text":"","code":"ggplot2::diamonds %>% dplyr::count(cut) %>% dplyr::mutate( or_worse = cumsum(n), or_better = cumsum_desc(n) ) #> # A tibble: 5 × 4 #> cut n or_worse or_better #> #> 1 Fair 1610 1610 53940 #> 2 Good 4906 6516 52330 #> 3 Very Good 12082 18598 47424 #> 4 Premium 13791 32389 35342 #> 5 Ideal 21551 53940 21551"},{"path":"https://ccsarapas.github.io/lighthouse/reference/d_to_OR.html","id":null,"dir":"Reference","previous_headings":"","what":"Conversion between Cohen's d and odds ratio — d_to_OR","title":"Conversion between Cohen's d and odds ratio — d_to_OR","text":"Functions convert Cohen's d odds ratio vice versa.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/d_to_OR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conversion between Cohen's d and odds ratio — d_to_OR","text":"","code":"d_to_OR(d) OR_to_d(OR)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/datetimes_to_date.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert all datetimes in table to dates — datetimes_to_date","title":"Convert all datetimes in table to dates — datetimes_to_date","text":"Returns dataframe datetime columns (.e., class POSIXct POSIXlt) converted Date.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/datetimes_to_date.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert all datetimes in table to dates — datetimes_to_date","text":"","code":"datetimes_to_date(.data)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/days_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Number of days between two dates — days_diff","title":"Number of days between two dates — days_diff","text":"Returns number days two dates.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/days_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Number of days between two dates — days_diff","text":"","code":"days_diff(d1, d2, warn = TRUE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/df_compare.html","id":null,"dir":"Reference","previous_headings":"","what":"Compare two data frames and show differences — df_compare","title":"Compare two data frames and show differences — df_compare","text":"Given two data frames dimensions column order, returns data frame including rows columns differences.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/df_compare.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compare two data frames and show differences — df_compare","text":"","code":"df_compare(x, y, suffix = c(\".x\", \".y\"), keep = NULL)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/df_compare.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compare two data frames and show differences — df_compare","text":"x, y pair data frames suffix suffixes indicate source data frame output. keep <[tidy-select][dplyr_tidy_select> Columns include output even differences.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/df_compare.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compare two data frames and show differences — df_compare","text":"data frame rows columns differing values x y. Differing columns included twice, suffixes appended. Columns specified keep always included.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/df_compare.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compare two data frames and show differences — df_compare","text":"","code":"x <- data.frame(id = 1:3, A = c(7, 8, 9), B = c(10, 20, 30), C = c(\"x\", \"y\", \"z\")) y <- data.frame(id = 1:3, A = c(7, 8, 99), B = c(10, 20, 30), C = c(\"X\", \"y\", \"Z\")) df_compare(x, y) #> A.x A.y C.x C.y #> 1 7 7 x X #> 2 9 99 z Z df_compare(x, y, keep = id) #> id A.x A.y C.x C.y #> 1 1 7 7 x X #> 2 3 9 99 z Z"},{"path":"https://ccsarapas.github.io/lighthouse/reference/discard_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove missing values — discard_na","title":"Remove missing values — discard_na","text":"Returns vector NAs removed. Similar stats::na.omit.default(), add attributes returned value.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/discard_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove missing values — discard_na","text":"","code":"discard_na(x)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/drop_na_rows.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop rows where all columns are NA — drop_na_rows","title":"Drop rows where all columns are NA — drop_na_rows","text":"Drops rows specified columns NA. columns specified, columns considered.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/drop_na_rows.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop rows where all columns are NA — drop_na_rows","text":"","code":"drop_na_rows(data, ...)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/drop_na_rows.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop rows where all columns are NA — drop_na_rows","text":"data data frame. ... (Optional) Columns test NAs. specified, columns considered.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/drop_na_rows.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Drop rows where all columns are NA — drop_na_rows","text":"data frame rows removed contain NA values across (specified) columns.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/drop_na_rows.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop rows where all columns are NA — drop_na_rows","text":"","code":"dat <- tibble::tibble( x = c(NA, NA, 3), y = c(NA, NA, 4), z = c(5, NA, NA) ) drop_na_rows(dat) #> # A tibble: 2 × 3 #> x y z #> #> 1 NA NA 5 #> 2 3 4 NA drop_na_rows(dat, x, y) #> # A tibble: 1 × 3 #> x y z #> #> 1 3 4 NA"},{"path":"https://ccsarapas.github.io/lighthouse/reference/dunn_test.html","id":null,"dir":"Reference","previous_headings":"","what":"Pairwise post-hoc test following Kruskal-Wallis test — dunn_test","title":"Pairwise post-hoc test following Kruskal-Wallis test — dunn_test","text":"tidy wrapper around dunn.test::dunn.test(). performs Dunn's test, non-parametric pairwise follow-Kruskal-Wallis test.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/dunn_test.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pairwise post-hoc test following Kruskal-Wallis test — dunn_test","text":"","code":"dunn_test( x, groups, data, p.adjust.method = c(\"holm\", \"hochberg\", \"bonferroni\", \"bh\", \"by\", \"sidak\", \"hs\", \"none\"), alpha = 0.05 )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/dunn_test.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pairwise post-hoc test following Kruskal-Wallis test — dunn_test","text":"x numeric vector. groups vector factor giving group corresponding elements x. data data frame containing variables. p.adjust.method character. method adjusting p-values multiple comparisons. alpha numeric. alpha level.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/dunn_test.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pairwise post-hoc test following Kruskal-Wallis test — dunn_test","text":"tibble columns: contrast: compared groups. statistic: Dunn's test statistic (z). adj.p.value: Adjusted p-value based specified p.adjust.method.","code":""},{"path":[]},{"path":"https://ccsarapas.github.io/lighthouse/reference/dunn_test.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pairwise post-hoc test following Kruskal-Wallis test — dunn_test","text":"","code":"mtcars2 <- transform(mtcars, cyl = factor(cyl)) kruskal.test(mpg ~ gear, data = mtcars2) #> #> \tKruskal-Wallis rank sum test #> #> data: mpg by gear #> Kruskal-Wallis chi-squared = 14.323, df = 2, p-value = 0.0007758 #> dunn_test(mpg, gear, data = mtcars2) #> # A tibble: 3 × 3 #> contrast statistic adj.p.value #> #> 1 3 - 4 -3.76 0.000253 #> 2 3 - 5 -1.65 0.0998 #> 3 4 - 5 1.14 0.127"},{"path":"https://ccsarapas.github.io/lighthouse/reference/eq_shape.html","id":null,"dir":"Reference","previous_headings":"","what":"Test if two objects have the same shape — eq_shape","title":"Test if two objects have the same shape — eq_shape","text":"Checks two objects x y shape, .e., dimensions length vectors.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/eq_shape.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test if two objects have the same shape — eq_shape","text":"","code":"eq_shape(x, y)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/eq_shape.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Test if two objects have the same shape — eq_shape","text":"x object. y object.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/eq_shape.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Test if two objects have the same shape — eq_shape","text":"TRUE x y shape, FALSE otherwise.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/eq_shape.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Test if two objects have the same shape — eq_shape","text":"","code":"eq_shape(1:5, 1:5) #> [1] TRUE eq_shape(1:5, 1:6) #> [1] FALSE eq_shape(matrix(1:6, nrow = 2), matrix(1:6, nrow = 3)) #> [1] FALSE eq_shape(matrix(1:6, nrow = 2), matrix(1:6, nrow = 2)) #> [1] TRUE"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_case_when.html","id":null,"dir":"Reference","previous_headings":"","what":"Results of case_when() as factor. — fct_case_when","title":"Results of case_when() as factor. — fct_case_when","text":"Wrapper dplyr::case_when(), result factor levels order passed .... Returns ordered factor .ordered TRUE.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_case_when.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Results of case_when() as factor. — fct_case_when","text":"","code":"fct_case_when(..., .ordered = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_collapse_alt.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse factor levels with additional controls — fct_collapse_alt","title":"Collapse factor levels with additional controls — fct_collapse_alt","text":"Collapses factor levels manually defined groups like forcats::fct_collapse(), additional options control behavior specified levels exist data order factor levels order listed.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_collapse_alt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse factor levels with additional controls — fct_collapse_alt","text":"","code":"fct_collapse_alt( .f, ..., other_level = NULL, reorder = TRUE, unknown_levels = c(\"ignore\", \"warn\", \"error\") )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_collapse_alt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse factor levels with additional controls — fct_collapse_alt","text":".f factor (character vector). ... series named character vectors. levels vector replaced name. other_level Value level used \"\" values named .... NULL, extra level created. reorder TRUE, collapsed levels ordered order listed ..., followed other_level specified, existing levels. unknown_levels handle levels listed ... present input factor .f. Options : \"ignore\": ignore unknown levels without warning (default), \"warn\": issue warning ignore unknown levels, \"error\": raise error.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_collapse_alt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse factor levels with additional controls — fct_collapse_alt","text":"factor collapsed levels.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_collapse_alt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse factor levels with additional controls — fct_collapse_alt","text":"","code":"f <- factor(c(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\")) fct_collapse_alt(f, EFG = c(\"e\", \"f\", \"g\"), AB = c(\"a\", \"b\")) #> [1] AB AB c d EFG EFG #> Levels: EFG AB c d fct_collapse_alt(f, EFG = c(\"e\", \"f\", \"g\"), AB = c(\"a\", \"b\"), reorder = FALSE) #> [1] AB AB c d EFG EFG #> Levels: AB c d EFG fct_collapse_alt(f, EFG = c(\"e\", \"f\", \"g\"), AB = c(\"a\", \"b\"), other_level = \"other\") #> [1] AB AB other other EFG EFG #> Levels: EFG AB other # `unknown_levels = \"warn\"` mirrors behavior of `forcats::fct_collapse()` # \\donttest{ fct_collapse_alt(f, EFG = c(\"e\", \"f\", \"g\"), AB = c(\"a\", \"b\"), unknown_levels = \"warn\") #> Warning: Unknown levels in `f`: g #> [1] AB AB c d EFG EFG #> Levels: EFG AB c d # }"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_filter.html","id":null,"dir":"Reference","previous_headings":"","what":"Filter by and drop factor levels simultaneously — fct_filter","title":"Filter by and drop factor levels simultaneously — fct_filter","text":"Filters dataframe specified levels .fct, drops filtered levels .fct.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_filter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filter by and drop factor levels simultaneously — fct_filter","text":"","code":"fct_filter(.data, .fct, .keep = NULL, .drop = NULL)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_na_if.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert specified factor levels to NA — fct_na_if","title":"Convert specified factor levels to NA — fct_na_if","text":"Converts specified level(s) factor NA, removing levels factor. differs behavior dplyr::na_if(), (1) replaces values NA retains associated factor level, (2) can replace single value.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_na_if.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert specified factor levels to NA — fct_na_if","text":"","code":"fct_na_if(x, y)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_na_if.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert specified factor levels to NA — fct_na_if","text":"x factor. y character vector levels convert NA.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_na_if.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert specified factor levels to NA — fct_na_if","text":"input factor specified levels converted NA removed levels.","code":""},{"path":[]},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_na_if.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert specified factor levels to NA — fct_na_if","text":"","code":"f <- factor(c(\"a\", \"b\", \"c\", \"a\")) fct_na_if(f, \"a\") #> [1] b c #> Levels: b c fct_na_if(f, c(\"a\", \"c\")) #> [1] b #> Levels: b # compare `na_if()` dplyr::na_if(f, \"a\") #> [1] b c #> Levels: a b c"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_reorder_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Reorder factor levels by sorting along multiple other variables. — fct_reorder_n","title":"Reorder factor levels by sorting along multiple other variables. — fct_reorder_n","text":"Reorders levels .f based variables passed ..., breaking ties using variable order passed.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fct_reorder_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reorder factor levels by sorting along multiple other variables. — fct_reorder_n","text":"","code":"fct_reorder_n(.f, ..., .desc = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/filter_drop.html","id":null,"dir":"Reference","previous_headings":"","what":"Filter by and drop a column simultaneously — filter_drop","title":"Filter by and drop a column simultaneously — filter_drop","text":"Filters dataframe specified values .col, drops .col.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/filter_drop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filter by and drop a column simultaneously — filter_drop","text":"","code":"filter_drop(.data, .col, .keep = NULL, .drop = NULL)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/find_na_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Identify or remove columns with no data — find_na_cols","title":"Identify or remove columns with no data — find_na_cols","text":"find_na_cols() returns names columns .data values NA. drop_na_cols() returns dataset -NA columns removed.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/find_na_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Identify or remove columns with no data — find_na_cols","text":"","code":"find_na_cols(.data, cols = tidyselect::everything()) drop_na_cols(.data, cols = tidyselect::everything(), quietly = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/find_na_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Identify or remove columns with no data — find_na_cols","text":".data data frame data frame extension (e.g. tibble). cols Columns check. quietly FALSE, print columns dropped.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fiscal_year.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine fiscal year from date — fiscal_year","title":"Determine fiscal year from date — fiscal_year","text":"Given date, returns corresponding fiscal year, start date, end date. fiscal_year function allows specifying fiscal year start month, ffy sfy_il convenience wrappers: ffy: Federal fiscal year (starts October) sfy_il: Illinois state fiscal year (starts July)","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fiscal_year.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine fiscal year from date — fiscal_year","text":"","code":"fiscal_year(x, type = c(\"year\", \"date_first\", \"date_last\"), fiscal_start = 1) ffy(x, type = c(\"year\", \"date_first\", \"date_last\")) sfy_il(x, type = c(\"year\", \"date_first\", \"date_last\"))"},{"path":"https://ccsarapas.github.io/lighthouse/reference/fiscal_year.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine fiscal year from date — fiscal_year","text":"x date date-time object. type return: fiscal year (\"year\"), first day fiscal year (\"date_first\"), last day fiscal year (\"date_last\"). fiscal_start fiscal_year, month fiscal year starts (default 1 January).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fiscal_year.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine fiscal year from date — fiscal_year","text":"integer representing fiscal year Date representing start end fiscal year, depending type.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/fiscal_year.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine fiscal year from date — fiscal_year","text":"","code":"dt <- as.Date(\"2023-08-15\") fiscal_year(dt) #> [1] 2023 fiscal_year(dt, fiscal_start = 7) #> [1] 2024 fiscal_year(dt, type = \"date_first\", fiscal_start = 7) #> [1] \"2023-07-01\" fiscal_year(dt, type = \"date_last\", fiscal_start = 7) #> [1] \"2024-06-30\" ffy(dt) #> [1] 2023 sfy_il(dt) #> [1] 2024"},{"path":"https://ccsarapas.github.io/lighthouse/reference/floor_month.html","id":null,"dir":"Reference","previous_headings":"","what":"Floor methods for date objects — floor_month","title":"Floor methods for date objects — floor_month","text":"floor_month() floor_week() simple wrappers around lubridate::floor_date() round first day month week. floor_days() rounds nearest n-day increment. Floors defined relative earliest date x, unless different start date passed start. Default behavior differs lubridate::floor_date(x, unit = \"{n} days\"), \"resets\" floor first month month. lubridate-like behavior can achieved setting reset_monthly = TRUE.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/floor_month.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Floor methods for date objects — floor_month","text":"","code":"floor_month(x) floor_week(x, week_start = getOption(\"lubridate.week.start\", 7)) floor_days(x, n = 1L, start = min(x, na.rm = TRUE), reset_monthly = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/gain_missing_codes.html","id":null,"dir":"Reference","previous_headings":"","what":"Missing codes for GAIN ABS — gain_missing_codes","title":"Missing codes for GAIN ABS — gain_missing_codes","text":"Labelled missings used GAIN datasets.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/gain_missing_codes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Missing codes for GAIN ABS — gain_missing_codes","text":"","code":"gain_missing_codes"},{"path":"https://ccsarapas.github.io/lighthouse/reference/gain_missing_codes.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Missing codes for GAIN ABS — gain_missing_codes","text":"named numeric vector.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/gain_ss_score.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute time period scores for GAIN-SS scales — gain_ss_score","title":"Compute time period scores for GAIN-SS scales — gain_ss_score","text":"Pass scale items .... return columns score lifetime, past year, past 90 days, past month positive items","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/gain_ss_score.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute time period scores for GAIN-SS scales — gain_ss_score","text":"","code":"gain_ss_score(..., .prefix = NULL)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/get_col_types.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarize a dataframe's column types - DEPRECATED — get_col_types","title":"Summarize a dataframe's column types - DEPRECATED — get_col_types","text":"Deprecated favor cols_info(), provides information features stable. Returns class type column .data.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/get_col_types.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarize a dataframe's column types - DEPRECATED — get_col_types","text":"","code":"get_col_types(.data)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/ggview.html","id":null,"dir":"Reference","previous_headings":"","what":"Nicer ggplot rendering - DEPRECATED — ggview","title":"Nicer ggplot rendering - DEPRECATED — ggview","text":"function deprecated longer maintained. Improvements RStudio graphics make longer needed. Saves ggplot object .svg R temp directory, displays RStudio Viewer pane. Results better image quality Windows machines.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/ggview.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nicer ggplot rendering - DEPRECATED — ggview","text":"","code":"ggview( plot = ggplot2::last_plot(), width = NULL, height = NULL, type = c(\"svg\", \"png\") )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/glue_chr.html","id":null,"dir":"Reference","previous_headings":"","what":"Format and interpolate a string as character vector — glue_chr","title":"Format and interpolate a string as character vector — glue_chr","text":"wrapper around glue::glue() returns character vector rather \"glue\" object.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/glue_chr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format and interpolate a string as character vector — glue_chr","text":"","code":"glue_chr(...)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/glue_chr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format and interpolate a string as character vector — glue_chr","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://ccsarapas.github.io/lighthouse/reference/group_split_named.html","id":null,"dir":"Reference","previous_headings":"","what":"Split dataframe by named groups — group_split_named","title":"Split dataframe by named groups — group_split_named","text":"Divides .data named list dataframes defined grouping structure. Grouping variables can optionally passed .... nested list returned one grouping variable .nested = TRUE.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/group_split_named.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Split dataframe by named groups — group_split_named","text":"","code":"group_split_named( .data, ..., .keep = TRUE, .sep = \".\", .col_names = FALSE, .col_sep = \"_\", .nested = FALSE, .na.rm = FALSE, .add_groups = TRUE )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/group_split_named.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Split dataframe by named groups — group_split_named","text":"","code":"by_cyl_gear1 <- mtcars %>% group_split_named(cyl, gear, .col_names = TRUE) by_cyl_gear1$cyl_6.gear_4 #> # A tibble: 4 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> 4 17.8 6 168. 123 3.92 3.44 18.9 1 0 4 4 by_cyl_gear2 <- mtcars %>% group_split_named(cyl, gear, .col_names = TRUE, .nested = TRUE) by_cyl_gear2$cyl_6 #> $gear_3 #> # A tibble: 2 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1 #> 2 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1 #> #> $gear_4 #> # A tibble: 4 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> 4 17.8 6 168. 123 3.92 3.44 18.9 1 0 4 4 #> #> $gear_5 #> # A tibble: 1 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 19.7 6 145 175 3.62 2.77 15.5 0 1 5 6 #> by_cyl_gear2$cyl_6$gear_4 #> # A tibble: 4 × 11 #> mpg cyl disp hp drat wt qsec vs am gear carb #> #> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> 4 17.8 6 168. 123 3.92 3.44 18.9 1 0 4 4"},{"path":"https://ccsarapas.github.io/lighthouse/reference/group_with_total.html","id":null,"dir":"Reference","previous_headings":"","what":"Add ","title":"Add ","text":"Groups dataframe columns specified ... using dplyr::group_by(), adds additional group containing observations. Useful including \"total\" \"overall\" row summaries. one column passed ..., \"total\" group combine groups first column passed, unless different column specified .totals_for. Removing changing grouping structure calling group_with_total() aggregating may yield inaccurate results.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/group_with_total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add ","text":"","code":"group_with_total( .data, ..., .totals_for = NULL, .label = \"Total\", .add = FALSE, .drop = dplyr::group_by_drop_default(.data), .first_row = FALSE )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/group_with_total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add ","text":"","code":"ggplot2::mpg %>% group_with_total(class) %>% dplyr::summarize(n = dplyr::n(), cty = mean(cty), hwy = mean(hwy)) #> # A tibble: 8 × 4 #> class n cty hwy #> #> 1 2seater 5 15.4 24.8 #> 2 compact 47 20.1 28.3 #> 3 midsize 41 18.8 27.3 #> 4 minivan 11 15.8 22.4 #> 5 pickup 33 13 16.9 #> 6 subcompact 35 20.4 28.1 #> 7 suv 62 13.5 18.1 #> 8 Total 234 16.9 23.4 ggplot2::mpg %>% group_with_total(year, drv, .label = \"all years\") %>% dplyr::summarize(n = dplyr::n(), cty = mean(cty), hwy = mean(hwy)) #> `summarise()` has grouped output by 'year'. You can override using the #> `.groups` argument. #> # A tibble: 9 × 5 #> # Groups: year [3] #> year drv n cty hwy #> #> 1 1999 4 49 14.2 18.8 #> 2 1999 f 57 20.0 27.9 #> 3 1999 r 11 14 20.6 #> 4 2008 4 54 14.4 19.5 #> 5 2008 f 49 20.0 28.4 #> 6 2008 r 14 14.1 21.3 #> 7 all years 4 103 14.3 19.2 #> 8 all years f 106 20.0 28.2 #> 9 all years r 25 14.1 21 ggplot2::mpg %>% group_with_total(year, drv, .totals_for = drv) %>% dplyr::summarize(n = dplyr::n(), cty = mean(cty), hwy = mean(hwy)) #> `summarise()` has grouped output by 'year'. You can override using the #> `.groups` argument. #> # A tibble: 8 × 5 #> # Groups: year [2] #> year drv n cty hwy #> #> 1 1999 4 49 14.2 18.8 #> 2 1999 f 57 20.0 27.9 #> 3 1999 r 11 14 20.6 #> 4 1999 Total 117 17.0 23.4 #> 5 2008 4 54 14.4 19.5 #> 6 2008 f 49 20.0 28.4 #> 7 2008 r 14 14.1 21.3 #> 8 2008 Total 117 16.7 23.5"},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_chestnut.html","id":null,"dir":"Reference","previous_headings":"","what":"CHS holidays over a 20-year period — holidays_chestnut","title":"CHS holidays over a 20-year period — holidays_chestnut","text":"dataset containing dates Chestnut Health System holidays 2010-12-31 2030-12-31.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_chestnut.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"CHS holidays over a 20-year period — holidays_chestnut","text":"","code":"holidays_chestnut"},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_chestnut.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"CHS holidays over a 20-year period — holidays_chestnut","text":"tibble 140 rows 2 variables: Date date holiday observed Holiday holiday name","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_il.html","id":null,"dir":"Reference","previous_headings":"","what":"Illinois state holidays over a 20-year period — holidays_il","title":"Illinois state holidays over a 20-year period — holidays_il","text":"dataset containing dates State Illinois holidays 2010-12-31 2030-12-31.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_il.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Illinois state holidays over a 20-year period — holidays_il","text":"","code":"holidays_il"},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_il.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Illinois state holidays over a 20-year period — holidays_il","text":"tibble 252 rows 2 variables: Date date holiday observed Holiday holiday name","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_us.html","id":null,"dir":"Reference","previous_headings":"","what":"US federal holidays over a 20-year period — holidays_us","title":"US federal holidays over a 20-year period — holidays_us","text":"dataset containing dates United States federal holidays 2010-12-31 2030-12-31.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_us.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"US federal holidays over a 20-year period — holidays_us","text":"","code":"holidays_us"},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_us.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"US federal holidays over a 20-year period — holidays_us","text":"tibble 212 rows 2 variables: Date date holiday observed Holiday holiday name","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/holidays_us.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"US federal holidays over a 20-year period — holidays_us","text":"https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/in_excel.html","id":null,"dir":"Reference","previous_headings":"","what":"Open dataframe in Excel — in_excel","title":"Open dataframe in Excel — in_excel","text":"Saves dataframe .csv R temp directory, opens Excel. .csv randomly-generated name unless otherwise specified name.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/in_excel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Open dataframe in Excel — in_excel","text":"","code":"in_excel(df, name, na = \"\")"},{"path":"https://ccsarapas.github.io/lighthouse/reference/in_excel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Open dataframe in Excel — in_excel","text":"df dataframe open Excel. name (Optional) name use .csv file. provided, random name generated. na (Optional) string use missing values .csv file. Defaults empty string.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_TRUE.html","id":null,"dir":"Reference","previous_headings":"","what":"Vectorized logical tests — is_TRUE","title":"Vectorized logical tests — is_TRUE","text":"is_TRUE() is_FALSE() vectorized versions base::isTRUE() base::isFALSE(), respectively. is_TRUE() returns TRUE vector element evaluates TRUE, FALSE elements (including NAs non-logical values). Useful handling NAs logical tests.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_TRUE.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Vectorized logical tests — is_TRUE","text":"","code":"is_TRUE(x, strict = TRUE) is_FALSE(x, strict = TRUE) is_TRUE_or_NA(x, strict = TRUE) is_FALSE_or_NA(x, strict = TRUE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_TRUE.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Vectorized logical tests — is_TRUE","text":"x Vector tested strict TRUE (default), numeric character types always return FALSE. FALSE, numeric character vectors can coerced logical (e.g., 1, \"FALSE\") coerced testing.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_coercible_numeric.html","id":null,"dir":"Reference","previous_headings":"","what":"Test for data encoded as other formats — is_coercible_numeric","title":"Test for data encoded as other formats — is_coercible_numeric","text":"Tests whether element vector can coerced another type. See examples.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_coercible_numeric.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test for data encoded as other formats — is_coercible_numeric","text":"","code":"is_coercible_numeric(x, all = FALSE, na = c(\"NA\", \"TRUE\")) is_coercible_integer(x, all = FALSE, na = c(\"NA\", \"TRUE\")) is_coercible_logical( x, all = FALSE, na = c(\"NA\", \"TRUE\"), numeric = c(\"binary\", \"any\") )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_coercible_numeric.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Test for data encoded as other formats — is_coercible_numeric","text":"x Vector tested TRUE, returns single logical indicating whether every element x coercible. FALSE (default), returns logical vector length x testing element x. na NA values test NA (default) TRUE? numeric is_coercible_logical, numeric value test TRUE, 0 1 (default)?","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_coercible_numeric.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Test for data encoded as other formats — is_coercible_numeric","text":"","code":"x <- c(\"1\", \"-1.23\", \"$1,234\", NA) is_coercible_numeric(x) #> [1] TRUE TRUE FALSE NA is_coercible_numeric(x, na = \"TRUE\") #> [1] TRUE TRUE FALSE TRUE is_coercible_numeric(x, all = TRUE) #> [1] FALSE is_coercible_integer(x) #> [1] TRUE FALSE FALSE NA y <- c(\"TRUE\", \"T\", \"F\", \"YES\", \"NA\", NA) is_coercible_logical(y) #> [1] TRUE TRUE TRUE FALSE FALSE NA z <- c(0, 1, 2, .1, -1) is_coercible_logical(z) #> [1] TRUE TRUE FALSE FALSE FALSE is_coercible_logical(z, numeric = \"any\") #> [1] TRUE TRUE TRUE TRUE TRUE"},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_duplicate.html","id":null,"dir":"Reference","previous_headings":"","what":"Identify duplicates within a vector or vectors — is_duplicate","title":"Identify duplicates within a vector or vectors — is_duplicate","text":"function checks duplicated values within vector set vectors.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_duplicate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Identify duplicates within a vector or vectors — is_duplicate","text":"","code":"is_duplicate(..., nmax = 1, incomparables = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_duplicate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Identify duplicates within a vector or vectors — is_duplicate","text":"... one vectors equal length. nmax maximum number times value can appear considered duplicate. incomparables missing values (including NaN) considered duplicates?","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_duplicate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Identify duplicates within a vector or vectors — is_duplicate","text":"logical vector.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_duplicate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Identify duplicates within a vector or vectors — is_duplicate","text":"","code":"x <- c(1, 2, 2, 3, 3, 3) y <- c(1, 1, 2, 1, 2, 2) is_duplicate(x) #> [1] FALSE TRUE TRUE TRUE TRUE TRUE is_duplicate(x, nmax = 2) #> [1] FALSE FALSE FALSE TRUE TRUE TRUE is_duplicate(x, y) #> [1] FALSE FALSE FALSE FALSE TRUE TRUE z <- c(1, NA, NA) is_duplicate(z) #> [1] FALSE FALSE FALSE is_duplicate(z, incomparables = TRUE) #> [1] FALSE TRUE TRUE"},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_spss.html","id":null,"dir":"Reference","previous_headings":"","what":"Test whether a data frame contains SPSS variable or value labels — is_spss","title":"Test whether a data frame contains SPSS variable or value labels — is_spss","text":"Checks data frame contains SPSS / haven variable labels, value labels, format attributes.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_spss.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test whether a data frame contains SPSS variable or value labels — is_spss","text":"","code":"is_spss(.data)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_spss.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Test whether a data frame contains SPSS variable or value labels — is_spss","text":".data data frame.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_spss.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Test whether a data frame contains SPSS variable or value labels — is_spss","text":"TRUE data frame contains SPSS labels, FALSE otherwise.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_valid.html","id":null,"dir":"Reference","previous_headings":"","what":"Identify non-missing values — is_valid","title":"Identify non-missing values — is_valid","text":"wrapper around !.na(x).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/is_valid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Identify non-missing values — is_valid","text":"","code":"is_valid(x) is.valid(x)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/median_dbl.html","id":null,"dir":"Reference","previous_headings":"","what":"Median value as double - DEPRECATED — median_dbl","title":"Median value as double - DEPRECATED — median_dbl","text":"Deprecated lighthouse 0.7.0. main use case function avoid type errors dplyr::if_else() case_when(), longer necessary changes introduced dplyr v1.1.0. Returns median x double vector. Alternative stats::median() consistent return value needed.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/median_dbl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Median value as double - DEPRECATED — median_dbl","text":"","code":"median_dbl(x, na.rm = FALSE, ...)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/median_dbl.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Median value as double - DEPRECATED — median_dbl","text":"","code":"if (FALSE) { # \\dontrun{ # stats::median raises error because of inconsistent return types ### note this no longer raises an error with dplyr >= 1.1.0 dplyr::if_else(c(TRUE, FALSE), median(1:4), median(1:5)) # Error in `dplyr::if_else()`: # ! `false` must be a double vector, not an integer vector. # dplyr::if_else(c(TRUE, FALSE), median_dbl(1:4), median_dbl(1:5)) # 2.5 3.0 } # }"},{"path":"https://ccsarapas.github.io/lighthouse/reference/n_valid.html","id":null,"dir":"Reference","previous_headings":"","what":"Count non-missing cases — n_valid","title":"Count non-missing cases — n_valid","text":"n_valid() returns number vector elements NA. returns percentage non-NA values = \"pct\", tibble containing number percentage = \"n_pct\". pct_valid() wrapper around n_valid(= \"pct\"). n_pct_valid() wrapper around n_pct_valid(= \"n_pct\").","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/n_valid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count non-missing cases — n_valid","text":"","code":"n_valid(x, out = c(\"n\", \"pct\", \"n_pct\"), ...) pct_valid(x, ...) n_pct_valid(x, ...)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_if_range.html","id":null,"dir":"Reference","previous_headings":"","what":"Set NA values based on range of numbers. — na_if_range","title":"Set NA values based on range of numbers. — na_if_range","text":"Changes values range range_min range_max NA. Works numeric vectors well numbers character vectors, factor labels, numeric character vectors classes labelled haven_labelled.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_if_range.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set NA values based on range of numbers. — na_if_range","text":"","code":"na_if_range(x, range_min = -Inf, range_max = -1) # S3 method for class 'numeric' na_if_range(x, range_min = -Inf, range_max = -1) # S3 method for class 'character' na_if_range(x, range_min = -Inf, range_max = -1) # S3 method for class 'factor' na_if_range(x, range_min = -Inf, range_max = -1) # S3 method for class 'labelled' na_if_range(x, range_min = -Inf, range_max = -1) # S3 method for class 'haven_labelled' na_if_range(x, range_min = -Inf, range_max = -1) coerce_na_range(x, range_min = -Inf, range_max = -1)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_if_range.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set NA values based on range of numbers. — na_if_range","text":"x numeric vector, character vector, factor. range_min minimum value set NA. Defaults -Inf. range_max maximum value set NA. Defaults -1.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_if_range.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Set NA values based on range of numbers. — na_if_range","text":"Previously known coerce_na_range, retained alias backward compatibility.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_like.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate NA values of appropriate type - DEPRECATED — na_like","title":"Generate NA values of appropriate type - DEPRECATED — na_like","text":"function deprecated lighthouse 0.7.0 (1) always buggy (2) main purpose pass appropriate NAs dplyr::if_else() case_when(), longer necessary changes introduced dplyr v1.1.0 Returns compatible NA based x. usually type x (e.g., NA_real_ x double vector). x factor, return NA_character_ factor_as_character = TRUE (default) NA_integer_ otherwise.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_like.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate NA values of appropriate type - DEPRECATED — na_like","text":"","code":"na_like(x, factor_as_character = TRUE, match_length = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_to_null.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace NA with NULL and vice versa — na_to_null","title":"Replace NA with NULL and vice versa — na_to_null","text":"na_to_null() Replaces NAs vector list NULL. Can useful lists function arguments (e.g., using purrr::pmap()). null_to_na() Replaces NULLs list NAs. Returns atomic vector unlist = TRUE list otherwise.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/na_to_null.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace NA with NULL and vice versa — na_to_null","text":"","code":"na_to_null(x) null_to_na(x, unlist = FALSE)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/not-in.html","id":null,"dir":"Reference","previous_headings":"","what":"Match values not in vector — not-in","title":"Match values not in vector — not-in","text":"Infix operator returning TRUE elements left operand (lhs) found right operand (rhs). Equivalent !(lhs %% rhs).","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/not-in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Match values not in vector — not-in","text":"","code":"lhs %!in% rhs"},{"path":"https://ccsarapas.github.io/lighthouse/reference/not-in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Match values not in vector — not-in","text":"","code":"\"April\" %!in% month.name #> [1] FALSE \"Junvember\" %!in% month.name #> [1] TRUE some_letters <- sample(letters, 10) letters[letters %in% some_letters] #> [1] \"c\" \"d\" \"e\" \"k\" \"n\" \"o\" \"q\" \"t\" \"v\" \"y\" letters[letters %!in% some_letters] #> [1] \"a\" \"b\" \"f\" \"g\" \"h\" \"i\" \"j\" \"l\" \"m\" \"p\" \"r\" \"s\" \"u\" \"w\" \"x\" \"z\""},{"path":"https://ccsarapas.github.io/lighthouse/reference/nth_valid.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the nth, first, or last non-NA value in a vector — nth_valid","title":"Get the nth, first, or last non-NA value in a vector — nth_valid","text":"functions retrieve nth, first last non-NA value vector. fewer n non-NA values, default value can returned.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/nth_valid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the nth, first, or last non-NA value in a vector — nth_valid","text":"","code":"nth_valid(x, n, default = NA) first_valid(x, default = NA) last_valid(x, default = NA)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/nth_valid.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the nth, first, or last non-NA value in a vector — nth_valid","text":"x vector. n integer. Position non-NA value return. Negative values start end vector. default default value use fewer n non-NA values x. cast type x.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/nth_valid.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the nth, first, or last non-NA value in a vector — nth_valid","text":"nth_valid: nth non-NA value x. first_valid: first non-NA value x. last_valid: last non-NA value x.","code":""},{"path":[]},{"path":"https://ccsarapas.github.io/lighthouse/reference/nth_valid.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the nth, first, or last non-NA value in a vector — nth_valid","text":"","code":"x <- c(NA, 7, NA, 5, 4, NA, 2, NA) first_valid(x) #> [1] 7 last_valid(x) #> [1] 2 nth_valid(x, 2) #> [1] 5 nth_valid(x, -2) #> [1] 4 nth_valid(x, 6) #> [1] NA nth_valid(x, 6, default = -Inf) #> [1] -Inf"},{"path":"https://ccsarapas.github.io/lighthouse/reference/opacity.html","id":null,"dir":"Reference","previous_headings":"","what":"Translate colors before and after alpha blending — opacity","title":"Translate colors before and after alpha blending — opacity","text":"functions translate colors original RGB values RGB values alpha blending background color. before_opacity calculates original color given blended color, after_opacity calculates blended color given original color.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/opacity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Translate colors before and after alpha blending — opacity","text":"","code":"after_opacity(color, alpha, bg = \"white\") before_opacity(color, alpha, bg = \"white\")"},{"path":"https://ccsarapas.github.io/lighthouse/reference/opacity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Translate colors before and after alpha blending — opacity","text":"color starting color color name, hex code, RGB triplet. alpha opacity foreground color, number 0 1. bg background color blending, color name, hex code, RGB triplet. Defaults \"white\".","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/opacity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Translate colors before and after alpha blending — opacity","text":"before_opacity: original color alpha blending, hex code. after_opacity: blended color alpha blending, hex code.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/opacity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Translate colors before and after alpha blending — opacity","text":"","code":"red <- \"red\" red_50 <- after_opacity(red, 0.5) red_back <- before_opacity(red_50, 0.5) scales::show_col(c(red, red_50, red_back), ncol = 3) color_blends <- sapply( c(\"red\", \"blue\", \"yellow\", \"white\", \"black\", \"gray50\"), after_opacity, color = \"red\", alpha = 0.5 ) scales::show_col(color_blends)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/open_file.html","id":null,"dir":"Reference","previous_headings":"","what":"Open a file or directory — open_file","title":"Open a file or directory — open_file","text":"Functions open file default program open file's location file explorer.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/open_file.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Open a file or directory — open_file","text":"","code":"open_file(path) open_location(path) file.open(path) dir.open(path)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/open_file.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Open a file or directory — open_file","text":"path path file directory.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/open_file.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Open a file or directory — open_file","text":"file.open() dir.open() aliases, line base::file.create, file.exists, dir.create, dir.exists, etc.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/open_file.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Open a file or directory — open_file","text":"open_file(): Opens file specified path using default program file type. Automatically handles paths special characters. open_location(): Opens file explorer location specified file, file selected possible. Automatically handles paths special characters.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/open_file.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Open a file or directory — open_file","text":"","code":"if (FALSE) { # \\dontrun{ # Open a file open_file(\"path/to/file.txt\") # Open a file's location open_location(\"path/to/file.txt\") } # }"},{"path":"https://ccsarapas.github.io/lighthouse/reference/p_to_OR.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert between probabilities and odds ratios — p_to_OR","title":"Convert between probabilities and odds ratios — p_to_OR","text":"functions convert probabilities odds ratios. p_to_OR calculates odds ratio given two probabilities, OR_to_p2 OR_to_p1 calculate second first probability, respectively, given probability odds ratio.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/p_to_OR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert between probabilities and odds ratios — p_to_OR","text":"","code":"p_to_OR(p1, p2) OR_to_p2(p1, OR) OR_to_p1(p2, OR)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/p_to_OR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert between probabilities and odds ratios — p_to_OR","text":"p1 first probability. p2 second probability. odds ratio.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/p_to_OR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert between probabilities and odds ratios — p_to_OR","text":"p_to_OR: odds ratio corresponding given probabilities. OR_to_p2: second probability corresponding given first probability odds ratio. OR_to_p1: first probability corresponding given second probability odds ratio.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/p_to_OR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert between probabilities and odds ratios — p_to_OR","text":"","code":"p_to_OR(0.4, 0.6) #> [1] 2.25 OR_to_p2(0.4, 2.25) #> [1] 0.6 OR_to_p1(0.6, 2.25) #> [1] 0.4"},{"path":"https://ccsarapas.github.io/lighthouse/reference/pad_vectors.html","id":null,"dir":"Reference","previous_headings":"","what":"Pad vectors to the same length — pad_vectors","title":"Pad vectors to the same length — pad_vectors","text":"function takes one vectors pads NA values length longest vector.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/pad_vectors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pad vectors to the same length — pad_vectors","text":"","code":"pad_vectors(...)"},{"path":"https://ccsarapas.github.io/lighthouse/reference/pad_vectors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pad vectors to the same length — pad_vectors","text":"... One vectors.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/pad_vectors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pad vectors to the same length — pad_vectors","text":"list vectors, length longest input vector.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/pad_vectors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Pad vectors to the same length — pad_vectors","text":"","code":"pad_vectors(1:3, 1:5, 1:4) #> [[1]] #> [1] 1 2 3 NA NA #> #> [[2]] #> [1] 1 2 3 4 5 #> #> [[3]] #> [1] 1 2 3 4 NA #> # supports list unpacking with `!!!` operator pad_vectors(!!!list(1:3, 1:5, 1:4)) #> [[1]] #> [1] 1 2 3 NA NA #> #> [[2]] #> [1] 1 2 3 4 5 #> #> [[3]] #> [1] 1 2 3 4 NA #> # one use case is assembling vectors of different lengths into a dataframe # for example, to see unique column values at a glance: unique_vals <- dplyr::starwars %>% dplyr::select(hair_color:eye_color) %>% lapply(unique) pad_vectors(!!!unique_vals) %>% as.data.frame() #> hair_color skin_color eye_color #> 1 blond fair blue #> 2 gold yellow #> 3 none white, blue red #> 4 brown white brown #> 5 brown, grey light blue-gray #> 6 black white, red black #> 7 auburn, white unknown orange #> 8 auburn, grey green hazel #> 9 white green-tan, brown pink #> 10 grey pale unknown #> 11 auburn metal red, blue #> 12 blonde dark gold #> 13 brown mottle green, yellow #> 14 brown white #> 15 grey dark #> 16 mottled green #> 17 orange #> 18 blue, grey #> 19 grey, red #> 20 red #> 21 blue #> 22 grey, blue #> 23 grey, green, yellow #> 24 yellow #> 25 tan #> 26 fair, green, yellow #> 27 silver, red #> 28 green, grey #> 29 red, blue, white #> 30 brown, white #> 31 none "},{"path":"https://ccsarapas.github.io/lighthouse/reference/pivot_wider_alt.html","id":null,"dir":"Reference","previous_headings":"","what":"Alternative column ordering and naming for pivot_wider() — pivot_wider_alt","title":"Alternative column ordering and naming for pivot_wider() — pivot_wider_alt","text":"Note 2024, pivot_wider_alt()'s functionality now supported tidyr::pivot_wider(). particular, functionality names_value_first = TRUE pivot_wider_alt() can now achieved using names_vary = \"slowest\" pivot_wider(). functionality names_value_sep can achieved using names_glue argument pivot_wider(). wrapper around tidyr::pivot_wider() additional options sorting naming output columns, arguments sort_by_col, names_value_first, names_value_sep options relevant one input column passed values_from.","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/pivot_wider_alt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Alternative column ordering and naming for pivot_wider() — pivot_wider_alt","text":"","code":"pivot_wider_alt( data, id_cols = NULL, names_from = name, sort_by_col = TRUE, names_value_first = TRUE, names_value_sep = \".\", names_sep = \"_\", names_prefix = \"\", names_glue = NULL, names_repair = \"check_unique\", values_from = value, values_fill = NULL, values_fn = NULL )"},{"path":"https://ccsarapas.github.io/lighthouse/reference/pivot_wider_alt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Alternative column ordering and naming for pivot_wider() — pivot_wider_alt","text":"data data frame pivot. id_cols set columns uniquely identify observation. Typically used redundant variables, .e. variables whose values perfectly correlated existing variables. Defaults columns data except columns specified names_from values_from. tidyselect expression supplied, evaluated data removing columns specified names_from values_from. sort_by_col TRUE (default), output columns sorted names_from, values_from. (Differs tidyr::pivot_wider(), sorts values_from first, names_from.) names_value_first FALSE, output columns named using {column}_{.value} scheme. (Differs tidyr::pivot_wider(), uses {.value}_{column} scheme.) names_value_sep, names_sep names_from values_from contain multiple variables, used join values together single string use column name. names_value_sep separate {.value} {column} components, names_sep separate {column} components one another names_from contains multiple variables. See Details Examples. names_prefix, names_glue, names_repair, values_from, values_fill, values_fn See documentation tidyr::pivot_wider().","code":""},{"path":"https://ccsarapas.github.io/lighthouse/reference/pivot_wider_alt.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Alternative column ordering and naming for pivot_wider() — pivot_wider_alt","text":"#' names_value_sep argument allows output column names use different separator {.value} {column} multiple {columns}s. Example:","code":"pivot_wider_alt( fakedata, names_from = c(size, color), # size = \"sm\", \"med\", \"lg\"; color = \"red\", \"blue\" values_from = c(n, weight), names_sep = \"_\", names_value_sep = \": \" ) # output column names: # `n: sm_red`, `weight: sm_red`, `n: sm_blue`, `weight: sm_blue`, `n: med_red`..."},{"path":"https://ccsarapas.github.io/lighthouse/reference/pivot_wider_alt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Alternative column ordering and naming for pivot_wider() — pivot_wider_alt","text":"","code":"data_ex <- ggplot2::diamonds %>% dplyr::group_by(cut, color) %>% dplyr::summarize(Min = min(price), Median = median(price), Max = max(price)) #> `summarise()` has grouped output by 'cut'. You can override using the `.groups` #> argument. # default pivot_wider() behavior data_ex %>% tidyr::pivot_wider( id_cols = color, names_from = cut, values_from = Min:Max ) #> # A tibble: 7 × 16 #> color Min_Fair Min_Good `Min_Very Good` Min_Premium Min_Ideal Median_Fair #>