diff --git a/R/add_totals.R b/R/add_totals.R index 39dc204f..a2170fd8 100644 --- a/R/add_totals.R +++ b/R/add_totals.R @@ -10,7 +10,6 @@ #' @return Returns a data.frame augmented with a totals row, column, or both. #' @export #' @examples -#' library(dplyr) # for the %>% pipe #' mtcars %>% #' crosstab(am, cyl) %>% #' adorn_totals() @@ -66,7 +65,6 @@ adorn_totals <- function(dat, which = c("row", "col"), fill = "-", na.rm = TRUE) #' @return Returns a data.frame with a totals row, consisting of "Total" in the first column and column sums in the others. #' @export #' @examples -#' library(dplyr) # for the %>% pipe #' mtcars %>% #' crosstab(am, cyl) %>% #' add_totals_row @@ -88,7 +86,6 @@ add_totals_row <- function(dat, fill = "-", na.rm = TRUE){ #' @return Returns a data.frame with a totals column containing row-wise sums. #' @export #' @examples -#' library(dplyr) # for the %>% pipe #' mtcars %>% #' crosstab(am, cyl) %>% #' add_totals_col diff --git a/R/adorn_crosstab.R b/R/adorn_crosstab.R index fc37b496..c2cee1dd 100644 --- a/R/adorn_crosstab.R +++ b/R/adorn_crosstab.R @@ -13,7 +13,6 @@ #' @param rounding method to use for truncating percentages - either "half to even", the base R default method, or "half up", where 14.5 rounds up to 15. #' @return Returns a data.frame. #' @examples -#' library(dplyr) # for the %>% pipe #'mtcars %>% #' crosstab(gear, cyl) %>% #' adorn_crosstab(denom = "all") diff --git a/R/clean_names.R b/R/clean_names.R index 68d021c0..5b4c7272 100644 --- a/R/clean_names.R +++ b/R/clean_names.R @@ -12,7 +12,7 @@ #' # not run: #' # clean_names(poorly_named_df) #' -#' # library(dplyr) ; library(readxl) +#' # library(readxl) #' # not run: #' # readxl("messy_excel_file.xlsx") %>% clean_names() diff --git a/R/crosstab.R b/R/crosstab.R index 3cab8e0b..80970c1f 100644 --- a/R/crosstab.R +++ b/R/crosstab.R @@ -27,12 +27,12 @@ #' crosstab(mtcars$cyl, mtcars$gear, "row") #' #' # Passing in a data.frame using a pipeline: -#' library(dplyr) # to access the pipe operator #' mtcars %>% crosstab(cyl, gear) #' mtcars %>% crosstab(cyl, gear, "row") #' #' # This allows for upstream operations #' # prior to the crosstab() call: +#' library(dplyr) #' mtcars %>% #' filter(am == 0) %>% #' crosstab(cyl, gear) diff --git a/R/get_dupes.R b/R/get_dupes.R index 9f082d3c..af57fa3c 100644 --- a/R/get_dupes.R +++ b/R/get_dupes.R @@ -9,8 +9,7 @@ #' @export #' @examples #' get_dupes(mtcars, mpg, hp) -#' # or called with magrittr pipe %>% : -#' library(dplyr) +#' # or called with the magrittr pipe %>% : #' mtcars %>% get_dupes(wt) #' diff --git a/R/ns_to_percents.R b/R/ns_to_percents.R index c5b8abd8..d32e532f 100644 --- a/R/ns_to_percents.R +++ b/R/ns_to_percents.R @@ -11,7 +11,6 @@ #' @return Returns a data.frame of percentages, expressed as numeric values between 0 and 1. #' @export #' @examples -#' library(dplyr) # for the %>% pipe #' mtcars %>% #' crosstab(am, cyl) %>% #' ns_to_percents(denom = "all") diff --git a/R/remove_empties.R b/R/remove_empties.R index 3eeb1ae4..e063283a 100644 --- a/R/remove_empties.R +++ b/R/remove_empties.R @@ -7,8 +7,6 @@ #' @return Returns the data.frame with no empty rows. #' @export #' @examples -#' # called with magrittr pipe %>% : -#' # library(dplyr) #' # not run: #' # dat %>% remove_empty_rows @@ -25,8 +23,6 @@ remove_empty_rows <- function(dat){ #' @return Returns the data.frame with no empty columns. #' @export #' @examples -#' # called with magrittr pipe %>% : -#' # library(dplyr) #' # not run: #' # dat %>% remove_empty_cols #' diff --git a/R/tabyl.R b/R/tabyl.R index b54713ec..74e523e7 100644 --- a/R/tabyl.R +++ b/R/tabyl.R @@ -23,7 +23,6 @@ #' tabyl(mtcars$cyl, sort = TRUE) #' #' # Passing in a data.frame using a pipeline: -#' library(dplyr) # to access the pipe operator #' mtcars %>% tabyl(cyl, sort = TRUE) #' #' # illustrating show_na functionality: diff --git a/R/utils.R b/R/utils.R index 8a69c3b5..a11c0024 100644 --- a/R/utils.R +++ b/R/utils.R @@ -2,7 +2,7 @@ #' Pipe operator #' -#' See \code{\link[magrittr]{\%>\%}} for more details. +#' @description Exported from the magrittr package. To learn more, run \code{?magrittr::`\%>\%`}. #' #' @name %>% #' @rdname pipe @@ -10,4 +10,8 @@ #' @export #' @importFrom magrittr %>% #' @usage lhs \%>\% rhs +#' @examples +#' mtcars %>% +#' crosstab(carb, cyl) %>% +#' adorn_totals() NULL \ No newline at end of file diff --git a/man/add_totals_col.Rd b/man/add_totals_col.Rd index d05b955a..fa574f61 100644 --- a/man/add_totals_col.Rd +++ b/man/add_totals_col.Rd @@ -18,7 +18,6 @@ Returns a data.frame with a totals column containing row-wise sums. This function is deprecated, use \code{adorn_totals} instead. } \examples{ -library(dplyr) # for the \%>\% pipe mtcars \%>\% crosstab(am, cyl) \%>\% add_totals_col diff --git a/man/add_totals_row.Rd b/man/add_totals_row.Rd index 2b19f83c..07100a3f 100644 --- a/man/add_totals_row.Rd +++ b/man/add_totals_row.Rd @@ -20,7 +20,6 @@ Returns a data.frame with a totals row, consisting of "Total" in the first colum This function is deprecated, use \code{adorn_totals} instead. } \examples{ -library(dplyr) # for the \%>\% pipe mtcars \%>\% crosstab(am, cyl) \%>\% add_totals_row diff --git a/man/adorn_crosstab.Rd b/man/adorn_crosstab.Rd index e0548449..d103145e 100644 --- a/man/adorn_crosstab.Rd +++ b/man/adorn_crosstab.Rd @@ -29,7 +29,6 @@ Formats a data.frame containing counts of co-occurences of two variables (i.e., Designed to run on the output of a call to \code{janitor::crosstab}, but can be called on any data.frame containing a contingency table, e.g., the result of \code{dplyr::count()} followed by \code{tidyr::spread()}. } \examples{ -library(dplyr) # for the \%>\% pipe mtcars \%>\% crosstab(gear, cyl) \%>\% adorn_crosstab(denom = "all") diff --git a/man/adorn_totals.Rd b/man/adorn_totals.Rd index e968af05..0ca0ce50 100644 --- a/man/adorn_totals.Rd +++ b/man/adorn_totals.Rd @@ -22,7 +22,6 @@ Returns a data.frame augmented with a totals row, column, or both. This function excludes the first column of the input data.frame, assuming it's a descriptive variable not to be summed. It also excludes other non-numeric columns. } \examples{ -library(dplyr) # for the \%>\% pipe mtcars \%>\% crosstab(am, cyl) \%>\% adorn_totals() diff --git a/man/clean_names.Rd b/man/clean_names.Rd index dd8eadaf..59184360 100644 --- a/man/clean_names.Rd +++ b/man/clean_names.Rd @@ -19,7 +19,7 @@ Resulting names are unique and consist only of the \code{_} character, lowercase # not run: # clean_names(poorly_named_df) -# library(dplyr) ; library(readxl) +# library(readxl) # not run: # readxl("messy_excel_file.xlsx") \%>\% clean_names() } diff --git a/man/crosstab.Rd b/man/crosstab.Rd index 63df7607..70211940 100644 --- a/man/crosstab.Rd +++ b/man/crosstab.Rd @@ -50,12 +50,12 @@ crosstab(mtcars$cyl, mtcars$gear) crosstab(mtcars$cyl, mtcars$gear, "row") # Passing in a data.frame using a pipeline: -library(dplyr) # to access the pipe operator mtcars \%>\% crosstab(cyl, gear) mtcars \%>\% crosstab(cyl, gear, "row") # This allows for upstream operations # prior to the crosstab() call: +library(dplyr) mtcars \%>\% filter(am == 0) \%>\% crosstab(cyl, gear) diff --git a/man/get_dupes.Rd b/man/get_dupes.Rd index 56440c8a..98b6de85 100644 --- a/man/get_dupes.Rd +++ b/man/get_dupes.Rd @@ -19,8 +19,7 @@ For hunting duplicate records during data cleaning. Specify the data.frame and } \examples{ get_dupes(mtcars, mpg, hp) -# or called with magrittr pipe \%>\% : -library(dplyr) +# or called with the magrittr pipe \%>\% : mtcars \%>\% get_dupes(wt) } diff --git a/man/ns_to_percents.Rd b/man/ns_to_percents.Rd index 22ea9f60..1c594482 100644 --- a/man/ns_to_percents.Rd +++ b/man/ns_to_percents.Rd @@ -22,7 +22,6 @@ Returns a data.frame of percentages, expressed as numeric values between 0 and 1 This function excludes the first column of the input data.frame, assuming that it contains a descriptive variable. } \examples{ -library(dplyr) # for the \%>\% pipe mtcars \%>\% crosstab(am, cyl) \%>\% ns_to_percents(denom = "all") diff --git a/man/pipe.Rd b/man/pipe.Rd index 51295fd8..e55a5633 100644 --- a/man/pipe.Rd +++ b/man/pipe.Rd @@ -7,6 +7,11 @@ lhs \%>\% rhs } \description{ -See \code{\link[magrittr]{\%>\%}} for more details. +Exported from the magrittr package. To learn more, run \code{?magrittr::`\%>\%`}. +} +\examples{ +mtcars \%>\% + crosstab(carb, cyl) \%>\% + adorn_totals() } \keyword{internal} diff --git a/man/remove_empty_cols.Rd b/man/remove_empty_cols.Rd index d28b2938..629024fb 100644 --- a/man/remove_empty_cols.Rd +++ b/man/remove_empty_cols.Rd @@ -16,8 +16,6 @@ Returns the data.frame with no empty columns. Removes all columns from a data.frame that are composed entirely of \code{NA} values. } \examples{ -# called with magrittr pipe \%>\% : -# library(dplyr) # not run: # dat \%>\% remove_empty_cols diff --git a/man/remove_empty_rows.Rd b/man/remove_empty_rows.Rd index 6461cd2e..cf34f749 100644 --- a/man/remove_empty_rows.Rd +++ b/man/remove_empty_rows.Rd @@ -16,8 +16,6 @@ Returns the data.frame with no empty rows. Removes all rows from a data.frame that are composed entirely of \code{NA} values. } \examples{ -# called with magrittr pipe \%>\% : -# library(dplyr) # not run: # dat \%>\% remove_empty_rows } diff --git a/man/tabyl.Rd b/man/tabyl.Rd index eba5af1e..14dd6754 100644 --- a/man/tabyl.Rd +++ b/man/tabyl.Rd @@ -42,7 +42,6 @@ tabyl(val) tabyl(mtcars$cyl, sort = TRUE) # Passing in a data.frame using a pipeline: -library(dplyr) # to access the pipe operator mtcars \%>\% tabyl(cyl, sort = TRUE) # illustrating show_na functionality: