/
stack_users.R
33 lines (29 loc) · 1.16 KB
/
stack_users.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#' Query information about users from the Stack Exchange API
#'
#' Query for a list of users, or information related to one or more
#' specific users.
#'
#' @param id A vector containing one or more user IDs
#' @param special One of many options to describe what information to
#' extract from each user
#' @template api_options
#'
#' @return A \code{data.frame} containing each returned user
#'
#' @return A \code{data.frame} of users
#'
#' @export
stack_users <- function(id = NULL, special = NULL, ...) {
special_id<- c("top-answer-tags", "top-question-tags", "top-tags",
"privileges", "notifications")
special_ids <- c("answers", "badges", "comments", "favorites", "mentioned",
"network-activity", "posts", "questions", "reputation",
"reputation-history", "suggested-edits", "tags",
special_id)
special_no_ids <- c("moderators")
if ((!is.null(special) && (special %in% special_id)) && length(id) > 1) {
stop(paste(special, "can be used only with a single ID"))
}
url <- combine_url("users", id, special, special_ids, special_no_ids)
stack_GET(url, ...)
}