Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up the pipe import #29

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(get_dataset)
export(get_resource)
export(get_resource_sql)
Expand Down
1 change: 0 additions & 1 deletion R/get_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' @seealso [get_resource()] for downloading a single resource
#' from a dataset.
#'
#' @importFrom magrittr %>%
#' @return a [tibble][tibble::tibble-package] with the data
#' @export
#'
Expand Down Expand Up @@ -68,7 +67,7 @@
)

# of matching name cols, find if types match too
inconsistent_index <- this_types[matching_names] != next_types[matching_names]

Check warning on line 70 in R/get_dataset.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_dataset.R,line=70,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.
inconsistencies[[i]] <- this_types[matching_names][inconsistent_index]
}

Expand All @@ -79,7 +78,7 @@
if (length(to_coerce) > 0) {
cli::cli_warn(c(
"Due to conflicts between column types across resources,
the following {cli::qty(to_coerce)} column{?s} ha{?s/ve} been coerced to type character:",

Check warning on line 81 in R/get_dataset.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_dataset.R,line=81,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 96 characters.
"{.val {to_coerce}}"
))
}
Expand Down
1 change: 0 additions & 1 deletion R/get_resource.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
#' @param res_id The resource ID as found on
#' \href{https://www.opendata.nhs.scot/}{NHS Open Data platform}
#' @param rows (optional) specify the max number of rows to return.
#' @param row_filters (optional) a named list or vector that specifies values of columns/fields to keep.

Check warning on line 6 in R/get_resource.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_resource.R,line=6,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 104 characters.
#' e.g. list(Date = 20220216, Sex = "Female").
#' @param col_select (optional) a character vector containing the names of desired columns/fields.

Check warning on line 8 in R/get_resource.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_resource.R,line=8,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 98 characters.
#' e.g. c("Date", "Sex").
#'
#' @seealso [get_dataset()] for downloading all resources
#' from a given dataset.
#'
#' @importFrom magrittr %>%
#' @return a [tibble][tibble::tibble-package] with the data
#' @export
#'
Expand All @@ -20,8 +19,8 @@
#' filters <- list("HB" = "S08000030", "Month" = "202109")
#' wanted_cols <- c("HB", "Month", "TotalPatientsSeen")
#'
#' df <- get_resource(res_id = res_id, row_filters = filters, col_select = wanted_cols)

Check warning on line 22 in R/get_resource.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_resource.R,line=22,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 87 characters.
get_resource <- function(res_id, rows = NULL, row_filters = NULL, col_select = NULL) {

Check warning on line 23 in R/get_resource.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_resource.R,line=23,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 86 characters.
# check res_id
check_res_id(res_id)

Expand Down
1 change: 0 additions & 1 deletion R/get_resource_sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
#'
#' ```sql = "SELECT * FROM \"<res_id>\" WHERE \"Age\" = '34'"```.
#'
#' @seealso [get_resource()] for downloading a resource without using a SQL query.

Check warning on line 28 in R/get_resource_sql.R

View workflow job for this annotation

GitHub Actions / lint

file=R/get_resource_sql.R,line=28,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.
#'
#' @importFrom magrittr %>%
#' @return a [tibble][tibble::tibble-package] with the query results.
#' Only 32,000 rows can be returned from a single SQL query.
#' @export
Expand Down
14 changes: 14 additions & 0 deletions R/utils-pipe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
#' @param lhs A value or the magrittr placeholder.
#' @param rhs A function call using the magrittr semantics.
#' @return The result of calling `rhs(lhs)`.
NULL
20 changes: 20 additions & 0 deletions man/pipe.Rd

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

Loading