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

add documentation to generate_ll_from_utm #108

Merged
merged 5 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Imports:
tidyselect,
glue,
sp,
withr
withr,
cli,
purrr
RoxygenNote: 7.3.1
Suggests:
knitr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export(get_taxon_rank)
export(get_utm_zone)
export(long2UTM)
export(order_cols)
export(removeEmptyTables)
export(replace_blanks)
export(te_check)
export(utm_to_ll)
Expand Down
24 changes: 24 additions & 0 deletions R/geography.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ fuzz_location <- function(lat,
#' of your dataframe. Note that some parameter names are not in snake_case but
#' instead reflect DarwinCore naming conventions.
#'
#' This function uses tidy evaluation (i.e. you can provide column name arguments
#' as strings or you can leave them unquoted). If you wish to store column names
#' as strings in variables, you must enclose the variables in double curly braces
#' when you pass them into the function. See code examples below.
#'
#' @param df - The dataframe with UTM coordinates you would like to convert.
#' Input the name of your dataframe.
#' @param EastingCol - The name of your Easting UTM column. You may input the name
Expand All @@ -372,6 +377,7 @@ fuzz_location <- function(lat,
#' @examples
#' \dontrun{
#'
#' # Using magrittr pipe (%>%) and unquoted column names
#' my_dataframe %>%
#' generate_ll_from_utm(
#' EastingCol = UTM_X,
Expand All @@ -380,6 +386,7 @@ fuzz_location <- function(lat,
#' DatumCol = Datum
#' )
#'
#' # Providing column names as strings (in quotes)
#' generate_ll_from_utm(
#' df = mydataframe,
#' EastingCol = "EastingCoords",
Expand All @@ -388,6 +395,23 @@ fuzz_location <- function(lat,
#' DatumCol = "datum",
#' latlong_datum = "WGS84"
#' )
#'
#' # Column names stored as strings in separate variables
#' easting <- "EastingCoords"
#' northing <- "NorthingCoords"
#' zonecol <- "zone"
#' datumcol <- "datum"
#' latlong_dat <- "WGS84"
#'
#' generate_ll_from_utm(
#' df = mydataframe,
#' EastingCol = {{easting}}, # enclose variables that store column names in {{}}
#' NorthingCol = {{northing}},
#' ZoneCol = {{zonecol}},
#' DatumCol = {{datumcol}},
#' latlong_datum = latlong_dat # this isn't a column name so it doesn't need {{}}
#' )
#'
#' }
generate_ll_from_utm <- function(df,
EastingCol,
Expand Down
26 changes: 26 additions & 0 deletions R/removeEmptyTables.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' Remove empty tables from a list
#'
#' @param df_list A list of tibbles or dataframes.
#'
#' @return The same list but with empty tables removed.
#' @export
#'
#' @examples
#'
#' test_list <- list(item_a = tibble::tibble,
#' item_b = mtcars,
#' item_c = iris)
#'
#' tidy_list <- removeEmptyTables(test_list)
#'
removeEmptyTables <- function(df_list) {
non_empty_list <- purrr::compact(df_list) # Remove empty dataframes
tables_removed <- setdiff(names(df_list), names(non_empty_list)) # Get names of removed dataframes

# Warn about removed empty dataframes
if (length(tables_removed) > 0) {
warning(cli::pluralize("{length(tables_removed)} empty table{?s} {?was/were} omitted from dataset. Affected table{?s}: {paste(tables_removed, collapse = ", ")}"))
}

return(non_empty_list)
}
4 changes: 2 additions & 2 deletions docs/404.html

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

4 changes: 2 additions & 2 deletions docs/LICENSE-text.html

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

4 changes: 2 additions & 2 deletions docs/LICENSE.html

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

4 changes: 2 additions & 2 deletions docs/articles/DRR_Purpose_and_Scope.html

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

Loading
Loading