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

pick_phylopic uuid argument #96

Merged
merged 2 commits into from
Dec 19, 2023
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
18 changes: 13 additions & 5 deletions R/pick_phylopic.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ utils::globalVariables(c("x", "y", "uuid", "label"))
#' @param n \code{numeric}. How many uuids should be viewed? Depending on the
#' requested `name`, multiple silhouettes may exist. If `n` exceeds the number
#' of available images, all available uuids will be returned. Defaults to 5.
#' Only relevant if `name` supplied.
#' @param uuid \code{character}. A vector (or list) of valid PhyloPic
#' silhouette uuids, such as that returned by [get_uuid()].
#' @param view \code{numeric}. Number of silhouettes that should be plotted at
#' the same time. Defaults to 1.
#' @param filter \code{character}. Filter uuid(s) by usage license. Use "by"
#' to limit results to image uuids which do not require attribution, "nc"
#' for image uuids which allow commercial usage, and "sa" for image uuids
#' without a ShareAlike clause. The user can also combine these filters.
#' without a ShareAlike clause. The user can also combine these filters. Only
#' relevant if `name` supplied.
#' @param auto \code{numeric}. This argument allows the user to automate input
#' into the menu choice. If the input value is `1`, the first returned image
#' will be selected. If the input value is `2`, requested images will be
Expand Down Expand Up @@ -52,7 +56,7 @@ utils::globalVariables(c("x", "y", "uuid", "label"))
#' # 3 x 3 pane layout
#' img <- pick_phylopic(name = "Scleractinia", n = 9, view = 9)
#' }
pick_phylopic <- function(name = NULL, n = 5, view = 1,
pick_phylopic <- function(name = NULL, n = 5, uuid = NULL, view = 1,
filter = NULL, auto = NULL) {
# Error handling
if (!is.null(auto) && !auto %in% c(1, 2)) {
Expand All @@ -79,9 +83,13 @@ pick_phylopic <- function(name = NULL, n = 5, view = 1,
gp = gpar(fontsize = 8, col = "purple", fontface = "bold"))
return(img)
}

# Get uuids
uuids <- get_uuid(name = name, n = n, filter = filter, url = FALSE)

if (is.null(uuid)) {
# Get uuids
uuids <- get_uuid(name = name, n = n, filter = filter, url = FALSE)
} else {
uuids <- unlist(uuid)
}
# Record length
n_uuids <- length(uuids)

Expand Down
18 changes: 15 additions & 3 deletions man/pick_phylopic.Rd

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

Loading