diff --git a/NAMESPACE b/NAMESPACE index 18b343f2..3c3d1094 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -72,7 +72,6 @@ export(get_tokens) export(get_trends) export(ids) export(invalidate_bearer) -export(lat_lng) export(links) export(list_expansions) export(list_fields) @@ -108,7 +107,6 @@ export(post_destroy) export(post_favorite) export(post_follow) export(post_friendship) -export(post_list) export(post_message) export(post_mute) export(post_tweet) diff --git a/R/api_v2_utils.R b/R/api_v2_utils.R index c639789b..04b9bf67 100644 --- a/R/api_v2_utils.R +++ b/R/api_v2_utils.R @@ -99,7 +99,7 @@ req_is_error <- function(resp) { } else { r <- resp } - has_name_(r, "errors") + has_name_(r, "errors") || httr2::resp_is_error(resp) } req_errors <- function(resp) { diff --git a/R/auth.R b/R/auth.R index 72c2b577..29320100 100644 --- a/R/auth.R +++ b/R/auth.R @@ -84,8 +84,6 @@ auth_setup_default <- function() { #' @export #' @examples #' \dontrun{ -#' rtweet_user() -#' rtweet_bot() #' rtweet_app() #' } rtweet_user <- function(client_id = NULL, client_secret = NULL, @@ -195,7 +193,7 @@ rtweet_bearer <- function(client = NULL, scopes = set_scopes()) { token_params = list(client_secret = client$secret, client_type = "third_party_app", grant_type = "refresh_token")) - attr(token, "app", TRUE) <- client + attr(token, "app") <- client token } diff --git a/R/clean_tweets.R b/R/clean_tweets.R index 35b561c6..eb157041 100644 --- a/R/clean_tweets.R +++ b/R/clean_tweets.R @@ -2,19 +2,11 @@ #' #' Removes from the text, users mentions, hashtags, urls and media. #' Some urls or other text might remain if it is not recognized as an entity by -#' the API. +#' the API. `r lifecycle::badge("deprecated")` #' @param x Tweets #' @param clean Type of elements to be removed. #' @return A vector with the text without the entities selected #' @export -#' @examples -#' if (auth_has_default()) { -#' tweets <- search_tweets("weather") -#' tweets -#' -#' # tweets -#' clean_tweets(tweets) -#' } clean_tweets <- function(x, clean = c("users", "hashtags", "urls", "media")) { if (is.character(x)) { abort("You should provide tweets with all the users and hashtags information", diff --git a/R/client.R b/R/client.R index 825e4eb0..b09101f9 100644 --- a/R/client.R +++ b/R/client.R @@ -183,9 +183,11 @@ no_client <- function(call = caller_env()) { #' @seealso scopes #' @export #' @examples +#' \donttest{ #' if (interactive()) { #' rtweet_client() #' } +#' } rtweet_client <- function(client_id, client_secret, app, scopes = NULL) { if (missing(client_id) && missing(client_secret) ) { diff --git a/R/coords.R b/R/coords.R index 7f9ddfbb..31bdd04e 100644 --- a/R/coords.R +++ b/R/coords.R @@ -44,12 +44,6 @@ #' lnd <- lookup_coords("london") #' bz <- lookup_coords("brazil") #' -#' ## pass a returned coords object to search_tweets -#' bztw <- search_tweets(geocode = bz) -#' -#' ## or stream tweets -#' ustw <- stream_tweets(usa, timeout = 10) -#' #' } #' #' @family geo diff --git a/R/direct_messages.R b/R/direct_messages.R index 7de6a402..238509a9 100644 --- a/R/direct_messages.R +++ b/R/direct_messages.R @@ -3,7 +3,7 @@ #' #' Returns all Direct Message events (both sent and received) within the last 30 #' days. Sorted in reverse-chronological order. Includes detailed information -#' about the sender and recipient. +#' about the sender and recipient. `r lifecycle::badge("deprecated")` #' #' @inheritParams TWIT_paginate_cursor #' @inheritParams stream @@ -13,10 +13,7 @@ #' \dontrun{ #' #' ## get my direct messages -#' dms <- direct_messages() -#' -#' ## inspect data structure -#' str(dms) +#' direct_messages() #' #' } #' @export @@ -62,16 +59,8 @@ direct_messages <- function(n = 50, #' #' ## get my direct messages #' dms <- direct_messages_received() -#' -#' ## inspect data structure -#' str(dms) -#' #' ## get direct messages I've sent #' sdms <- direct_messages_sent() -#' -#' ## inspect data structure -#' str(dms) -#' #' } #' #' @details Includes detailed information about the sender and diff --git a/R/do_call_rbind.R b/R/do_call_rbind.R index 85501af7..a9c1a756 100644 --- a/R/do_call_rbind.R +++ b/R/do_call_rbind.R @@ -2,7 +2,7 @@ #' Binds list of data frames while preserving attribute (tweets or users) data. #' #' Row bind lists of tweets/users data whilst also preserving and binding -#' users/tweets attribute data. +#' users/tweets attribute data. `r lifecycle::badge("deprecated")` #' #' @param x List of parsed tweets data or users data, each of which #' presumably contains an attribute of the other (i.e., users data @@ -13,28 +13,6 @@ #' [users_data()] or [tweets_data()] extractor #' functions. #' @family parsing -#' @examples -#' -#' if (auth_has_default()) { -#' -#' ## lapply through three different search queries -#' lrt <- lapply( -#' c("rstats OR tidyverse", "data science", "python"), -#' search_tweets, -#' n = 100 -#' ) -#' -#' ## convert list object into single parsed data rame -#' rt <- do_call_rbind(lrt) -#' -#' ## preview tweets data -#' rt -#' -#' ## preview users data -#' users_data(rt) -#' -#' } -#' #' @export do_call_rbind <- function(x) { do.call(rbind, x) diff --git a/R/entities.R b/R/entities.R index 0c7de29c..b4908c37 100644 --- a/R/entities.R +++ b/R/entities.R @@ -10,19 +10,6 @@ #' for users mentions the ids of the mentioned users are "user_id", "user_id_str" #' (not "id_str") #' @export -#' @examples -#' if (auth_has_default()) { -#' statuses <- c( -#' "567053242429734913", -#' "266031293945503744", -#' "440322224407314432" -#' ) -#' -#' ## lookup tweets data for given statuses -#' tw <- lookup_tweets(statuses) -#' entity(tw, "urls") -#' -#' } entity <- function(x, entity, ...) { UseMethod("entity") } diff --git a/R/extractors.R b/R/extractors.R index f5dbc221..8adcacf0 100644 --- a/R/extractors.R +++ b/R/extractors.R @@ -6,18 +6,6 @@ #' rtweet instead stores in special attributes and allows you to show them #' with the `user_data()` and `tweets_data()` helpers. #' -#' @examples -#' if (auth_has_default()) { -#' # find users from tweets -#' tweets <- search_tweets("r") -#' users_data(tweets) -#' full_search <- cbind(tweets, users_data(tweets)) -#' -#' # from tweets from users -#' users <- search_users("r") -#' tweets_data(users) -#' full_users <- cbind(users, tweets_data(users)) -#' } #' @return `user_data()` returns a data frame of users; `tweets_data()` #' returns a data frame of tweets. #' @param tweets A data frame of tweets. diff --git a/R/favorites.R b/R/favorites.R index eb70c7f0..d5fc0eeb 100644 --- a/R/favorites.R +++ b/R/favorites.R @@ -1,22 +1,15 @@ #' Get tweets liked/favorited by one or more users #' #' Returns up to 3,000 tweets liked/favorited for each `user`. +#' `r lifecycle::badge("deprecated")` #' #' @inheritParams TWIT_paginate_max_id #' @inheritParams get_timeline #' @inheritParams stream #' @return A tibble with one row for each tweet. #' @examples -#' if (auth_has_default()) { -#' # get likes for a single user -#' kfc <- get_favorites("KFC") -#' kfc -#' # get newer likes since last request -#' newer <- get_favorites("KFC", since_id = kfc) -#' -#' # get likes from multiple users -#' favs <- get_favorites(c("Lesdoggg", "pattonoswalt", "meganamram")) -#' favs +#' if (FALSE) { +#' get_favorites("KFC") #' } #' @family tweets #' @references diff --git a/R/followers.R b/R/followers.R index 8ff82127..0b997f06 100644 --- a/R/followers.R +++ b/R/followers.R @@ -1,7 +1,7 @@ #' Get user IDs for accounts following target user. #' #' Returns a list of user IDs for the accounts following specified -#' user. +#' user. `r lifecycle::badge("deprecated")` #' #' @inheritParams TWIT_paginate_cursor #' @inheritParams get_timeline @@ -9,13 +9,8 @@ #' @param page `r lifecycle::badge("deprecated")` Please use `cursor` instead. #' @references #' @examples -#' if (auth_has_default()) { +#' if (FALSE) { #' users <- get_followers("_R_Foundation") -#' users -#' -#' # use `cursor` to find the next "page" of results -#' more_users <- get_followers("_R_Foundation", cursor = users) -#' #' } #' @return A tibble data frame with one column named "from_id" with the #' followers and another one "to_id" with the user used as input. diff --git a/R/friends.R b/R/friends.R index d0df522b..d3e1fd27 100644 --- a/R/friends.R +++ b/R/friends.R @@ -1,7 +1,7 @@ #' Get user IDs of accounts followed by target user(s). #' #' Returns a list of user IDs for the accounts following BY one or -#' more specified users. +#' more specified users. `r lifecycle::badge("deprecated")` #' #' Generally, you should not need to set `n` to more than 5,000 since Twitter #' limits the number of people that you can follow (i.e. to follow more than @@ -18,9 +18,8 @@ #' retrieved. #' @references #' @examples -#' if (auth_has_default()) { -#' users <- get_friends("ropensci") -#' users +#' if (FALSE) { +#' get_friends("ropensci") #' } #' @return A tibble data frame with two columns, "from_id" for name or ID of target #' user and "to_id" for accounts ID they follow. diff --git a/R/graph-network.R b/R/graph-network.R index 6500ff10..01093cf9 100644 --- a/R/graph-network.R +++ b/R/graph-network.R @@ -1,6 +1,7 @@ #' Network data #' #' Retrieve data to know which users are connected to which users. +#' `r lifecycle::badge("deprecated")` #' #' @description #' * `network_data()` returns a data frame that can easily be converted to @@ -16,30 +17,6 @@ #' default value of `c("mention", "retweet", "reply", "quote")` #' @return A from/to data edge data frame #' @seealso network_graph -#' @examples -#' if (auth_has_default()) { -#' ## search for #rstats tweets -#' rstats <- search_tweets("#rstats", n = 200) -#' -#' ## create from-to data frame representing retweet/mention/reply connections -#' rstats_net <- network_data(rstats, c("retweet","mention","reply")) -#' -#' ## view edge data frame -#' rstats_net -#' -#' ## view user_id->screen_name index -#' attr(rstats_net, "idsn") -#' -#' ## if igraph is installed... -#' if (requireNamespace("igraph", quietly = TRUE)) { -#' -#' ## (1) convert directly to graph object representing semantic network -#' rstats_net <- network_graph(rstats) -#' -#' ## (2) plot graph via igraph.plotting -#' plot(rstats_net) -#' } -#' } #' @export network_data <- function(x, e = c("mention", "retweet", "reply", "quote")) { if (isTRUE(e) || (length(e) == 1 && e %in% c("semantics", "all"))) { diff --git a/R/ids.R b/R/ids.R index de6faa37..766b385d 100644 --- a/R/ids.R +++ b/R/ids.R @@ -5,15 +5,6 @@ #' @param x An object of the rtweet package. #' @param ... Other arguments currently unused. #' @export -#' @examples -#' if (auth_has_default()) { -#' users <- lookup_users(c("twitter", "rladiesglobal", "_R_Foundation")) -#' ids(users) -#' followers <- get_followers("_R_Foundation") -#' head(ids(followers)) -#' friends <- get_friends("_R_Foundation") -#' head(ids(friends)) -#' } ids <- function(x, ...) { UseMethod("ids") } diff --git a/R/lat_lng.R b/R/lat_lng.R index 8e83c32e..6d2fede0 100644 --- a/R/lat_lng.R +++ b/R/lat_lng.R @@ -5,7 +5,7 @@ #' Adds single-point latitude and longitude variables to tweets data. #' #' Appends parsed Twitter data with latitude and longitude variables -#' using all available geolocation information. +#' using all available geolocation information. `r lifecycle::badge("deprecated")` #' #' @param x Parsed Twitter data as returned by various rtweet #' functions. This should be a data frame with variables such as @@ -28,19 +28,6 @@ #' @return Returns updated data object with full information latitude #' and longitude vars. #' @family geo -#' @examples -#' -#' if (auth_has_default()) { -#' -#' ## stream tweets sent from the US -#' rt <- search_tweets(geocode = lookup_coords("usa")) -#' -#' ## use lat_lng to recover full information geolocation data -#' rtl_loc <- lat_lng(rt) -#' rtl_loc -#' } -#' -#' @export lat_lng <- function(x, coords = c("coords_coords", "bbox_coords", "geo_coords"), prefs = "bbox_coords") { stopifnot(is.data.frame(x)) coords <- match.arg(coords, several.ok = TRUE) diff --git a/R/links.R b/R/links.R index 4ff26eb5..bc2c543f 100644 --- a/R/links.R +++ b/R/links.R @@ -5,15 +5,6 @@ #' @param x An object of the rtweet package. #' @param ... Other arguments currently unused. #' @export -#' @examples -#' if (auth_has_default()) { -#' users <- lookup_users(c("twitter", "rladiesglobal", "_R_Foundation")) -#' links(users) -#' followers <- get_followers("_R_Foundation") -#' head(links(followers)) -#' friends <- get_friends("_R_Foundation") -#' head(links(friends)) -#' } links <- function(x, ...) { UseMethod("links") } diff --git a/R/lists_members.R b/R/lists_members.R index 8dcef4a2..10006068 100644 --- a/R/lists_members.R +++ b/R/lists_members.R @@ -9,19 +9,6 @@ #' @param owner_user optional The screen name or user ID of the user #' @param ... Other arguments used as parameters in query composition. #' @inheritParams stream -#' @examples -#' if (auth_has_default()) { -#' -#' ## get list members for a list of rstats experts using list_id -#' (rstats <- lists_members("1260528710559694850")) -#' -#' ## get list members for an rstats list using list topic slug -#' ## list owner's screen name -#' rstats <- lists_members(slug = "r-people", owner_user = "Lluis_Revilla") -#' rstats -#' -#' } -#' #' @family lists #' @export #' @references diff --git a/R/lists_memberships.R b/R/lists_memberships.R index 5995441e..938b82c6 100644 --- a/R/lists_memberships.R +++ b/R/lists_memberships.R @@ -3,24 +3,13 @@ #' Due to deleted or removed lists, the returned number of memberships #' is often less than the provided n value. This is a reflection of the API and #' not a unique quirk of rtweet. -#' +#' #' @inheritParams TWIT_paginate_cursor #' @inheritParams get_timeline #' @param filter_to_owned_lists When `TRUE`, will return only lists that #' authenticating user owns. -#' @param previous_cursor `r lifecycle::badge("deprecated")` Please use +#' @param previous_cursor `r lifecycle::badge("deprecated")` Please use #' `cursor` instead. -#' @examples -#' if (auth_has_default()) { -#' -#' ## get up to 1000 Twitter lists that include Nate Silver -#' R_foundation <- lists_memberships("_R_Foundation", n = 1000) -#' -#' ## view data -#' R_foundation -#' -#' } -#' #' @references #' @export lists_memberships <- function(user = NULL, @@ -40,15 +29,15 @@ lists_memberships <- function(user = NULL, params$filter_to_owned_lists <- TRUE } - r <- TWIT_paginate_cursor(token, "/1.1/lists/memberships", params, + r <- TWIT_paginate_cursor(token, "/1.1/lists/memberships", params, n = n, - cursor = cursor, + cursor = cursor, retryonratelimit = retryonratelimit, verbose = verbose, page_size = if (n >= 1000) 1000 else n, get_id = function(x) x$lists$id_str ) - + if (parse) { r <- parse_lists_list(r) } @@ -61,6 +50,6 @@ parse_lists_list <- function(x) { dfs <- lapply(lists, wrangle_into_clean_data, type = "list") dfs <- lapply(dfs, tibble::as_tibble) df <- do.call(rbind, dfs) - + copy_cursor(df, x) } diff --git a/R/lists_statuses.R b/R/lists_statuses.R index c3a045d2..f57e3179 100644 --- a/R/lists_statuses.R +++ b/R/lists_statuses.R @@ -17,11 +17,6 @@ #' @family lists #' @family tweets #' @return data -#' @examples -#' if (auth_has_default()) { -#' (rladies <- lists_statuses(list_id = "839186302968848384")) -#' (rladies <- lists_statuses(slug = "rladies1", owner_user = "RLadiesGlobal")) -#' } #' @export lists_statuses <- function(list_id = NULL, slug = NULL, diff --git a/R/lists_subscribers.R b/R/lists_subscribers.R index 3d6cbb48..c746a124 100644 --- a/R/lists_subscribers.R +++ b/R/lists_subscribers.R @@ -4,12 +4,6 @@ #' @inheritParams stream #' @param list_id required The numerical id of the list. #' @param slug,owner_user The list name (slug) and owner. -#' @examples -#' if (auth_has_default()) { -#' ## get subscribers of rladies list -#' rstats <- lists_subscribers(slug = "rladies1", owner_user = "rladiesglobal") -#' } -#' #' @family lists #' @family users #' @export diff --git a/R/lists_subscriptions.R b/R/lists_subscriptions.R index e5a14c65..6844f755 100644 --- a/R/lists_subscriptions.R +++ b/R/lists_subscriptions.R @@ -1,14 +1,8 @@ -#' Get list subscriptions of a given user but does not include the user's own +#' Get list subscriptions of a given user but does not include the user's own #' lists. #' #' @inheritParams TWIT_paginate_cursor #' @inheritParams get_timeline -#' @examples -#' if (auth_has_default()) { -#' ## get ropensci subscriptions -#' rstats <- lists_subscriptions(user = "rladiesglobal", n = 1000) -#' } -#' #' @family lists #' @references #' @export @@ -19,7 +13,7 @@ lists_subscriptions <- function(user, retryonratelimit = NULL, verbose = TRUE, token = NULL) { - + params <- list( count = n, cursor = cursor @@ -33,7 +27,7 @@ lists_subscriptions <- function(user, page_size = if (n >= 1000) 1000 else n, get_id = function(x) x$user_id ) - + if (parse) { out <- parse_lists_list(r) } diff --git a/R/lists_users.R b/R/lists_users.R index 35df258d..ca31c586 100644 --- a/R/lists_users.R +++ b/R/lists_users.R @@ -5,14 +5,6 @@ #' to be returned first. See description above for information on #' how this parameter works. #' @return data -#' @examples -#' if (auth_has_default()) { -#' -#' ## get lists subscribed to by R_Foundation -#' lists_users("ropensci") -#' -#' } -#' #' @family lists #' @export lists_users <- function(user = NULL, reverse = FALSE, token = NULL, parse = TRUE) { diff --git a/R/mentions.R b/R/mentions.R index 9798a4d0..7a1a31e7 100644 --- a/R/mentions.R +++ b/R/mentions.R @@ -3,7 +3,7 @@ #' Returns data on up to 200 of the most recent mentions (Tweets #' containing a users' screen_name) of the authenticating user. #' The timeline returned is the equivalent of the one seen when you view -#' your mentions on twitter.com. +#' your mentions on twitter.com. `r lifecycle::badge("deprecated")` #' #' @inheritParams TWIT_paginate_max_id #' @inheritParams stream @@ -11,14 +11,6 @@ #' query. #' @return Tibble of mentions data. #' @family tweets -#' @examples -#' if (auth_has_default()) { -#' tw <- get_mentions() -#' tw -#' -#' # newer mentions -#' get_mentions(since_id = tw) -#' } #' @references #' @export get_mentions <- function(n = 200, diff --git a/R/next_cursor.R b/R/next_cursor.R index b690a9cf..f48c7a1b 100644 --- a/R/next_cursor.R +++ b/R/next_cursor.R @@ -4,12 +4,6 @@ #' `cursor` argument of the functions that use [TWIT_paginate_cursor()]. #' #' @keywords internal -#' @examples -#' if (auth_has_default()) { -#' page1 <- get_followers("_R_Foundation") -#' page2 <- get_followers("_R_Foundation", cursor = page1) -#' } -#' @keywords internal #' @export next_cursor <- function(x) { if (is_string(x) || is_null(x)) { @@ -35,7 +29,7 @@ copy_cursor <- function(to, from) { #' Previous cursor #' -#' @description +#' @description #' `r lifecycle::badge("deprecated")` #' Reverse pagination is no longer supported. #' @@ -46,24 +40,13 @@ previous_cursor <- function(x) { } #' Extract min/max id (for id based pagination) -#' +#' #' These internal helpers extract the ids passed on to the `max_id` #' and `since_id` arguments to functions that use [TWIT_paginate_max_id()]. -#' +#' #' @keywords internal #' @param x Either a data frame of tweets or a character vector of status ids. #' @export -#' @examples -#' if (auth_has_default()) { -#' tw <- search_tweets("#rstats") -#' -#' # retrieve older tweets -#' older <- search_tweets("#rstats", max_id = tw) -#' even_older <- search_tweets("#rstats", max_id = older) -#' -#' # retrieve newer tweets -#' newer <- search_tweets("#rstats", since_id = tw) -#' } max_id <- function(x) { id <- find_id(x, "max_id") as.character(min(bit64::as.integer64(id)) - 1L) diff --git a/R/post-block.R b/R/post-block.R index 67e18817..339508fb 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -2,6 +2,7 @@ #' #' `user_block(...)` blocks or unblocks a target twitter user. #' `user_unblock(...)` is synonymous to `user_block(..., unblock=TRUE)`. +#' `r lifecycle::badge("deprecated")` #' #' @inheritParams get_timeline #' @param unblock Logical indicating whether to unblock the intended @@ -10,12 +11,6 @@ #' @export #' @references #' Block: -#' @examples -#' if (auth_has_default()) { -#' user_block("rtweet") -#' user_unblock("rtweet") -#' user_block("rtweet", unblock=TRUE) #<-same as the above -#' } user_block <- function(user, unblock = FALSE, token = NULL) { diff --git a/R/post-favorite.R b/R/post-favorite.R index 50647d8a..94b71708 100644 --- a/R/post-favorite.R +++ b/R/post-favorite.R @@ -1,5 +1,6 @@ #' Favorites target status id. #' +#' `r lifecycle::badge("deprecated")` #' @inheritParams lookup_users #' @param status_id Status id of target tweet. #' @param destroy Logical indicating whether to post (add) or @@ -7,11 +8,6 @@ #' @param include_entities Logical indicating whether to #' include entities object in return. #' @aliases post_favourite favorite_tweet -#' @examples -#' if (auth_has_default()) { -#' rt <- search_tweets("#rstats", n = 1) -#' post_favorite(rt$id_str) -#' } #' @family post #' @export #' @references diff --git a/R/post-list.R b/R/post-list.R index c5275055..8c4f4d16 100644 --- a/R/post-list.R +++ b/R/post-list.R @@ -1,6 +1,6 @@ #' Manage Twitter lists #' -#' Create, add users, and destroy Twitter lists +#' Create, add users, and destroy Twitter lists. `r lifecycle::badge("deprecated")` #' #' @inheritParams lookup_users #' @param users Character vectors of users to be added to list. @@ -14,45 +14,6 @@ #' @param list_id Optional, numeric ID of list. #' @param slug Optional, list slug. #' @return Response object from HTTP request. -#' @examples -#' \dontrun{ -#' -#' ## R related Twitter accounts -#' users <- c("_R_Foundation", "R_dev_news", "rweekly_live", "RConsortium", "rstats4ds", -#' "icymi_r", "rstatstweet", "RLadiesGlobal") -#' -#' ## create r-accounts list with 8 total users -#' (r_lst <- post_list(users, -#' "r-accounts", description = "R related accounts")) -#' -#' ## view list in browser at https://twitter.com//lists/r-accounts -#' -#' ## search for more rstats users -#' r_users <- search_users("rstats", n = 200) -#' -#' ## filter and select more users to add to list -#' more_users <- r_users$screen_name[r_users$verified] -#' -#' ## add more users to list- note: can only add up to 100 at a time -#' post_list(users = more_users, slug = "r-accounts") -#' -#' ## view updated list in browser (should be around 100 users) -#' ## view list in browser at https://twitter.com//lists/r-accounts -#' -#' drop_users <- "icymi_r" -#' -#' ## drop these users from the R list -#' post_list(users = drop_users, slug = "r-accounts", -#' destroy = TRUE) -#' -#' ## view updated list in browser (should be around 100 users) -#' ## view list in browser at https://twitter.com//lists/r-accounts -#' -#' ## delete list entirely -#' post_list(slug = "r-accounts", destroy = TRUE) -#' -#' } -#' @export #' @references #' Create: #' Destroy: diff --git a/R/post-tweet.R b/R/post-tweet.R index 837d4bbb..1b09aabb 100644 --- a/R/post-tweet.R +++ b/R/post-tweet.R @@ -1,5 +1,6 @@ #' Posts status update to user's Twitter account #' +#' `r lifecycle::badge("deprecated")` #' @inheritParams lookup_users #' @param status Character, tweet status. Must be 280 characters or less. #' @param media Length 1 character vector with a file path to video media **OR** @@ -34,45 +35,9 @@ #' @param display_coordinates Put a pin on the exact coordinates a tweet has #' been sent from. Value should be TRUE or FALSE. This parameter would apply #' only if you have provided a valid `lat/long` pair of valid values. -#' @examples -#' if (auth_has_default()) { -#' ## generate data to make/save plot (as a .png file) -#' x <- rnorm(300) -#' y <- x + rnorm(300, 0, .75) -#' col <- c(rep("#002244aa", 50), rep("#440000aa", 50)) -#' bg <- c(rep("#6699ffaa", 50), rep("#dd6666aa", 50)) -#' -#' ## create temporary file name -#' tmp <- tempfile(fileext = ".png") -#' -#' ## save as png -#' png(tmp, 6, 6, "in", res = 127.5) -#' par(tcl = -.15, family = "Inconsolata", -#' font.main = 2, bty = "n", xaxt = "l", yaxt = "l", -#' bg = "#f0f0f0", mar = c(3, 3, 2, 1.5)) -#' plot(x, y, xlab = NULL, ylab = NULL, pch = 21, cex = 1, -#' bg = bg, col = col, -#' main = "This image was uploaded by rtweet") -#' grid(8, lwd = .15, lty = 2, col = "#00000088") -#' dev.off() -#' -#' ## post tweet with media attachment -#' post_tweet("a tweet with media attachment", media = tmp, -#' media_alt_text = "Random points example of rtweet::post_tweet. -#' rtweet requires alt text with all media") -#' -#' # example of replying within a thread -#' ## first post -#' pt <- post_tweet(status="first in a thread") -#' -#' reply_id <- ids(pt) -#' -#' ## post reply -#' post_tweet("second in the thread", -#' in_reply_to_status_id = reply_id) -#' } #' @family post #' @aliases post_status +#' @seealso [tweet_post()] #' @export #' @references #' Tweet: diff --git a/R/post-user.R b/R/post-user.R index 6133d7ab..af4b4133 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -1,5 +1,6 @@ #' Follows target Twitter user. #' +#' `r lifecycle::badge("deprecated")` #' @inheritParams get_timeline #' @param destroy Logical indicating whether to post (add) or #' remove (delete) target tweet as favorite. @@ -11,11 +12,6 @@ #' @param retweets Logical indicating whether to enable retweets #' for target user. Defaults to true. #' @aliases follow_user -#' @examples -#' if (auth_has_default()) { -#' post_follow("_R_Foundation") -#' post_follow("rtweet", mute = TRUE) # Mute -#' } #' @family post #' @export #' @references diff --git a/R/post_destroy.R b/R/post_destroy.R index 03970304..95b26aaa 100644 --- a/R/post_destroy.R +++ b/R/post_destroy.R @@ -1,14 +1,10 @@ #' Delete status of user's Twitter account #' -#' Deletes a status of user's profile. +#' Deletes a status of user's profile. `r lifecycle::badge("deprecated")` #' @inheritParams post_tweet #' @export #' @references -#' @examples -#' if (auth_has_default()) { -#' pt <- post_tweet("Running #rtweet examples") -#' post_destroy(ids(pt)) -#' } +#' @seealso [tweet_delete()] post_destroy <- function(destroy_id, token = NULL) { stopifnot(is.character(destroy_id) && length(destroy_id) == 1) diff --git a/R/premium.R b/R/premium.R index ca21b4e5..d3fb0f67 100644 --- a/R/premium.R +++ b/R/premium.R @@ -7,6 +7,7 @@ #' See the info provided by Twitter and the "Developer Account" section. #' #' Note: The `env_name` must match the ones you set up for the token you are using. +#' `r lifecycle::badge("deprecated")` #' #' @inheritParams TWIT_paginate_max_id #' @inheritParams stream @@ -81,20 +82,7 @@ #' #' @return A tibble data frame of Twitter data. #' @family premium endpoints -#' @examples -#' -#' \dontrun{ -#' ## search fullarchive for up to 300 rstats tweets sent in Jan 2014 -#' rt <- search_fullarchive("#rstats", n = 300, env_name = "SetYourLabel", -#' fromDate = "201401010000", toDate = "201401312359") -#' -#' toDate <- format(Sys.time() - 60 * 60 * 24 * 7, "%Y%m%d%H%M") -#' -#' ## search 30day for up to 300 rstats tweets sent before the last week -#' rt <- search_30day("#rstats", n = 300, -#' env_name = "SetYourLabel", toDate = toDate) -#' } -#' +#' @seealso [tweet_search_recent()], [tweet_search_all()] #' @export search_fullarchive <- function(q, n = 100, fromDate = NULL, toDate = NULL, continue = NULL, diff --git a/R/rate_limit.R b/R/rate_limit.R index ee5cf535..c48d5e4b 100644 --- a/R/rate_limit.R +++ b/R/rate_limit.R @@ -1,29 +1,27 @@ #' Rate limit helpers #' -#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' @description #' * `rate_limit()` returns a tibble of info about all rate limits #' * `rate_limit_reset()` returns the next reset for a endpoint #' * `rate_limit_wait()` waits for the next reset for an endpoint -#' +#' #' You should not need to use these function in the usual operation of rtweet -#' because all paginated functions will wait on your behalf if you set +#' because all paginated functions will wait on your behalf if you set #' `retryonratelimit = TRUE`. #' #' @inheritParams lookup_users -#' @param resource_match An optional regular expression used to filter the +#' @param resource_match An optional regular expression used to filter the #' resources listed in returned rate limit data. #' @param endpoint Name of Twitter endpoint like `"lookup/users"`, #' `"/media/upload"`, or `"/feedback/show/:id"`. -#' @examples -#' if (auth_has_default()) { -#' rate_limit() -#' } #' @family tokens #' @export #' @references rate_limit <- function(resource_match = NULL, token = NULL) { json <- TWIT_get(token, "/1.1/application/rate_limit_status") - + resources <- unlist(unname(json$resources), recursive = FALSE) df <- tibble::tibble( resource = names(resources), @@ -33,11 +31,11 @@ rate_limit <- function(resource_match = NULL, token = NULL) { ) df$reset_at <- .POSIXct(df$reset_at) df$reset <- round(difftime(df$reset_at, Sys.time(), units = "mins")) - + if (!is.null(resource_match)) { df <- df[grepl(resource_match, df$resource), ] } - + df } @@ -45,24 +43,24 @@ rate_limit <- function(resource_match = NULL, token = NULL) { #' @rdname rate_limit rate_limit_reset <- function(endpoint, token = NULL) { endpoint <- gsub("^/", "", endpoint) - + resource <- strsplit(endpoint, "/")[[1]][[1]] params <- list(resource = resource) json <- TWIT_get(token, "/1.1/application/rate_limit_status", params) - + info <- json$resources[[resource]][[paste0("/", endpoint)]] if (is.null(info)) { stop("Unrecognised endpoint '", endpoint, "'", call. = FALSE) } - + if (info$remaining > 0) { Sys.time() } else { - .POSIXct(info$reset) + .POSIXct(info$reset) } } -#' @export +#' @export #' @rdname rate_limit rate_limit_wait <- function(endpoint, token = NULL) { reset <- unclass(rate_limit_reset(endpoint, token)) @@ -79,11 +77,11 @@ wait_until <- function(until, api, fps = 8, verbose = TRUE) { Sys.sleep(ceiling(seconds)) return() } - + if (seconds < 0) { return(invisible()) } - + pb <- progress::progress_bar$new( total = seconds * fps, format = paste0( @@ -92,7 +90,7 @@ wait_until <- function(until, api, fps = 8, verbose = TRUE) { ) ) withr::defer(pb$terminate()) - + while(Sys.time() < until) { Sys.sleep(1 / fps) mins <- round((until - unclass(Sys.time())) / 60) diff --git a/R/save_as_csv.R b/R/save_as_csv.R index ad514034..dce35626 100644 --- a/R/save_as_csv.R +++ b/R/save_as_csv.R @@ -184,20 +184,12 @@ unx_ids <- function(x) { #' Read comma separated value Twitter data. #' #' Reads Twitter data that was previously saved as a CSV file. -#' +#' `r lifecycle::badge("deprecated")` #' @param file Name of CSV file. #' @param unflatten Logical indicating whether to unflatten (separate hasthags #' and mentions columns on space, converting characters to lists), defaults #' to FALSE. #' @return A tbl data frame of Twitter data -#' @examples -#' -#' \dontrun{ -#' -#' ## read in data.csv -#' rt <- read_twitter_csv("data.csv") -#' -#' } #' @family datafiles #' @export read_twitter_csv <- function(file, unflatten = FALSE) { diff --git a/R/search_tweets.R b/R/search_tweets.R index 1d3923b0..49e54147 100644 --- a/R/search_tweets.R +++ b/R/search_tweets.R @@ -1,7 +1,7 @@ #' Get tweets data on statuses identified via search query. #' #' Returns Twitter statuses matching a user provided search -#' query. ONLY RETURNS DATA FROM THE PAST 6-9 DAYS. +#' query. `r lifecycle::badge("deprecated")` #' #' @param q Query to be searched, used to filter and select tweets to #' return from Twitter's REST API. Must be a character string not to @@ -58,26 +58,10 @@ #' It should also be noted Twitter's search API does not consist of #' an index of all Tweets. At the time of searching, the search API #' index includes between only 6-9 days of Tweets. -#' @examples -#' if (auth_has_default()) { -#' tweets <- search_tweets("weather") -#' tweets -#' -#' # data about the users who made those tweets -#' users_data(tweets) -#' -#' # Retrieve all the tweets made since the previous request -#' # (there might not be any if people aren't tweeting about the weather) -#' newer <- search_tweets("weather", since_id = tweets) -#' # Retrieve tweets made before the previous request -#' older <- search_tweets("weather", max_id = tweets) -#' -#' # Restrict to English only, and ignore retweets -#' tweets2 <- search_tweets("weather", lang = "en", include_rts = FALSE) -#' } #' @return List object with tweets and users each returned as a #' data frame. #' @family tweets +#' @seealso [tweet_search_recent()], [tweet_search_all()] #' @export #' @references search_tweets <- function(q, n = 100, @@ -166,29 +150,11 @@ search_params <- function(q, #' #' search_tweets2 Passes all arguments to search_tweets. Returns data from #' one OR MORE search queries. +#' `r lifecycle::badge("deprecated")` #' #' @return A tbl data frame with additional "query" column. #' @rdname search_tweets -#' @examples -#' if (auth_has_default()) { -#' -#' ## search using multiple queries -#' st2 <- search_tweets2( -#' c("\"data science\"", "rstats OR python"), -#' n = 500 -#' ) -#' -#' ## preview tweets data -#' st2 -#' -#' ## preview users data -#' users_data(st2) -#' -#' ## check breakdown of results by search query -#' table(st2$query) -#' -#' } -#' +#' @seealso [tweet_search_recent()] #' @export search_tweets2 <- function(...) { dots <- match_fun(list(...), "search_tweets") diff --git a/R/search_users.R b/R/search_users.R index 235266ec..bc1172ab 100644 --- a/R/search_users.R +++ b/R/search_users.R @@ -1,24 +1,16 @@ #' Search for users #' #' Search for Twitter users. The Twitter API limits the results to at most -#' 1,000 users. +#' 1,000 users. `r lifecycle::badge("deprecated")` #' #' @inheritParams TWIT_paginate_max_id #' @inheritParams stream #' @param q As string providing the search query. Try searching by interest, #' full name, company name, or location. Exact match searches are not #' supported. -#' @examples -#' if (auth_has_default()) { -#' users <- search_users("#rstats", n = 300) -#' users -#' -#' # latest tweet from each user -#' tweets_data(users) -#' } -#' #' @return Data frame with one row for each matching user. #' @family users +#' @seealso [user_search()] #' @export #' @references search_users <- function(q, n = 100, diff --git a/R/statuses.R b/R/statuses.R index 5b427c59..1f4d8357 100644 --- a/R/statuses.R +++ b/R/statuses.R @@ -1,24 +1,13 @@ #' Get tweets data for given statuses (status IDs). #' +#' `r lifecycle::badge("deprecated")` #' @inheritParams lookup_users #' @inheritParams stream #' @param statuses User id or screen name of target user. #' @references -#' @examples -#' -#' if (auth_has_default()) { -#' statuses <- c( -#' "567053242429734913", -#' "266031293945503744", -#' "440322224407314432" -#' ) -#' -#' ## lookup tweets data for given statuses -#' tw <- lookup_tweets(statuses) -#' tw -#' } #' @return A tibble of tweets data. #' @family tweets +#' @seealso [tweet_search_recent()] #' @export lookup_tweets <- function(statuses, parse = TRUE, token = NULL, retryonratelimit = NULL, verbose = TRUE) { @@ -176,13 +165,6 @@ check_reply_settings <- function(options) { #' @seealso [tweet_post()], [tweet_search_recent()], [user_timeline()] #' @export #' @references -#' @examples -#' if (FALSE) { -#' # It requires Oauth authentication -#' tp <- tweet_post("Running examples of #rtweet") -#' td <- tweet_delete(tp$id) -#' } -#' tweet_delete <- function(id, verbose = FALSE, token = NULL) { stopifnot("Requires valid ids." = is_id(id)) if (length(id) == 1) { @@ -211,7 +193,6 @@ tweet_delete <- function(id, verbose = FALSE, token = NULL) { #' @inheritParams tweet_get #' @inheritParams tweet_search_recent #' @param id At least a tweet id. -#' @seealso [lookup_tweets()] [tweet_get()] #' @references #' One tweet: #' @export diff --git a/R/stream.R b/R/stream.R index 6a4b5f86..1c6957dd 100644 --- a/R/stream.R +++ b/R/stream.R @@ -1,5 +1,6 @@ #' Collect a live stream of Twitter data #' +#' `r lifecycle::badge("deprecated")` #' @description #' Streams public statuses to a file via one of the following four methods: #' @@ -35,24 +36,9 @@ #' @param verbose If `TRUE`, display a progress bar. #' @param parse Use `FALSE` to opt-out of parsing the tweets. #' @param ... Other arguments passed in to query parameters. -#' @seealso [parse_stream()]. +#' @seealso [filtered_stream()]. #' @references #' They were removed from the website. -#' @examples -#' \dontrun{ -#' # stream tweets mentioning "#rstats" for 10 seconds -#' rstats1 <- stream_tweets("#rstats", timeout = 10, file_name = "rstats.json") -#' rstats1 -#' -#' # Download another 10s worth of data to the same file -#' rstats2 <- stream_tweets("#rstats", timeout = 10, file_name = "rstats.json", -#' append = TRUE) -#' -#' # stream tweets about continental USA for 10 seconds -#' usa <- stream_tweets(location = lookup_coords("usa"), file_name = "usa.json", -#' timeout = 10) -#' -#' } #' @return A tibble with one row per tweet #' @export #' @references @@ -214,6 +200,7 @@ stream_params <- function(stream, ...) { #' Parser of stream #' #' Converts Twitter stream data (JSON file) into parsed data frame. +#' `r lifecycle::badge("deprecated")` #' @param path Character, name of JSON file with data collected by #' [stream_tweets()]. #' @param ... Unused, keeping it for back compatibility. diff --git a/R/timeline.R b/R/timeline.R index fdeb5891..c12674a0 100644 --- a/R/timeline.R +++ b/R/timeline.R @@ -3,7 +3,7 @@ #' `get_timeline()` returns the timeline of any Twitter user (i.e. what they #' have tweeted). `get_my_timeline()` returns the home timeline for the #' authenticated user (i.e. the tweets you see when you log into Twitter). -#' +#' `r lifecycle::badge("deprecated")` #' At most up to 3,200 of a user's most recent Tweets can be retrieved. #' #' @inheritParams TWIT_paginate_max_id @@ -17,22 +17,8 @@ #' @param ... Further arguments passed on as parameters in API query. #' @return A tbl data frame of tweets data with users data attribute. #' @references -#' @examples -#' if (auth_has_default()) { -#' tw <- get_timeline("_R_Foundation") -#' tw -#' -#' # get tweets that arrived since the last request -#' get_timeline("_R_Foundation", since_id = tw) -#' # get earlier tweets -#' get_timeline("_R_Foundation", max_id = tw) -#' -#' # get timelines for multiple users -#' tw <- get_timeline(c("_R_Foundation", "rOpenSci", "Bioconductor")) -#' tw -#' } -#' #' @family tweets +#' @seealso [user_timeline()] #' @export get_timeline <- function(user = NULL, n = 100, diff --git a/R/trends.R b/R/trends.R index 3f38bb6f..4ee8d67b 100644 --- a/R/trends.R +++ b/R/trends.R @@ -1,5 +1,6 @@ #' Get Twitter trends data. #' +#' `r lifecycle::badge("deprecated")` #' @inheritParams lookup_users #' @param woeid Numeric, WOEID (Yahoo! Where On Earth ID) or character #' string of desired town or country. Users may also supply latitude @@ -19,37 +20,6 @@ #' exclude hashtags. Defaults to FALSE--meaning, hashtags are #' included in returned trends. #' @inheritParams stream -#' @examples -#' if (auth_has_default()) { -#' -#' ## Retrieve available trends -#' trends <- trends_available() -#' trends -#' -#' ## Store WOEID for Worldwide trends -#' worldwide <- trends$woeid[grep("world", trends$name, ignore.case = TRUE)[1]] -#' -#' ## Retrieve worldwide trends datadata -#' ww_trends <- get_trends(worldwide) -#' -#' ## Preview trends data -#' ww_trends -#' -#' ## Retrieve trends data using latitude, longitude near New York City -#' nyc_trends <- get_trends(lat = 40.7, lng = -74.0) -#' -#' ## should be same result if lat/long supplied as first argument -#' nyc_trends <- get_trends(c(40.7, -74.0)) -#' -#' ## Preview trends data -#' nyc_trends -#' -#' ## Provide a city or location name using a regular expression string to -#' ## have the function internals do the WOEID lookup/matching for you -#' (luk <- get_trends("london")) -#' -#' } -#' #' @return Tibble data frame of trends data for a given geographical area. #' @family trends #' @export @@ -144,16 +114,9 @@ format_trend_date <- function(x) { #' Available Twitter trends along with associated WOEID. #' +#' `r lifecycle::badge("deprecated")` #' @inheritParams lookup_users #' -#' @examples -#' if (auth_has_default()) { -#' ## Retrieve available trends -#' trends <- trends_available() -#' trends -#' -#' } -#' #' @return Data frame with WOEID column. WOEID is a Yahoo! Where On #' Earth ID. #' @family trends diff --git a/R/ts_plot.R b/R/ts_plot.R index 58c03c2c..530fc4d3 100644 --- a/R/ts_plot.R +++ b/R/ts_plot.R @@ -1,7 +1,7 @@ #' Plots tweets data as a time series-like data object. #' #' Creates a ggplot2 plot of the frequency of tweets over a specified -#' interval of time. +#' interval of time. `r lifecycle::badge("deprecated")` #' #' @param data Data frame or grouped data frame. #' @param by Desired interval of time expressed as numeral plus one of @@ -16,19 +16,8 @@ #' @return If #' [ggplot2](https://cran.r-project.org/package=ggplot2) is #' installed then a [ggplot2::ggplot()] plot object. -#' @examples -#' -#' if (auth_has_default()) { -#' ## search for tweets containing "rstats" -#' rt <- search_tweets("rstats", n = 100) -#' -#' ## plot frequency in 1 min intervals -#' ts_plot(rt, "mins") -#' -#' ## examine all Twitter activity using weekly intervals -#' ts_plot(rt, "hours") -#' } #' @family ts_data +#' @keywords internal #' @export ts_plot <- function(data, by = "days", trim = 0L, tz ="UTC", ...) { lifecycle::deprecate_stop("2.0.0", function_call()) @@ -51,7 +40,7 @@ ts_plot <- function(data, by = "days", trim = 0L, tz ="UTC", ...) { #' Converts tweets data into time series-like data object. #' #' Returns data containing the frequency of tweets over a specified -#' interval of time. +#' interval of time. `r lifecycle::badge("deprecated")` #' #' @param data Data frame or grouped data frame. #' @param by Desired interval of time expressed as numeral plus one of @@ -62,22 +51,7 @@ ts_plot <- function(data, by = "days", trim = 0L, tz ="UTC", ...) { #' each time series #' @param tz Time zone to be used, defaults to "UTC" (Twitter default) #' @return Data frame with time, n, and grouping column if applicable. -#' @examples -#' if (auth_has_default()) { -#' -#' ## handles of women senators -#' orgs <- c("_R_Foundation", "ropensci") -#' -#' ## get timelines for each -#' orgs_tml <- get_timeline(orgs, n = 100) -#' -#' ## get single time series for tweets -#' ts_data(orgs_tml) -#' -#' ## using weekly intervals -#' ts_data(orgs_tml, "weeks") -#' } -#' +#' @keywords internal #' @export ts_data <- function(data, by = "days", trim = 0L, tz ="UTC") { lifecycle::deprecate_stop("2.0.0", function_call()) diff --git a/R/tweet_shot.R b/R/tweet_shot.R index df5c3f37..91c7f15f 100644 --- a/R/tweet_shot.R +++ b/R/tweet_shot.R @@ -3,6 +3,7 @@ #' Provide a status id or a full Twitter link to a tweet and this function #' will capture an image of the tweet --- or tweet + thread (if there are #' Twitter-linked replies) --- from the mobile version of said tweet/thread. +#' `r lifecycle::badge("deprecated")` #' #' For this to work, you will need to ensure the packages in `Suggests:` are #' installed as they will be loaded upon the first invocation of this function. diff --git a/R/tweet_threading.R b/R/tweet_threading.R index 4f588000..e77accdc 100644 --- a/R/tweet_threading.R +++ b/R/tweet_threading.R @@ -4,6 +4,7 @@ #' own tweets). By default the function traverses first backwards from the #' origin status_id of the thread up to the root, then checks if there are any #' child statuses that were posted after the origin status. +#' `r lifecycle::badge("deprecated")` #' #' The backwards method looks up the tweet which is replying to, so it works if #' starting from the last tweet of the thread. @@ -16,11 +17,6 @@ #' It is not recommended to change the default if you don't know at which point of a thread you are starting. #' @param verbose logical, output to console status of traverse. #' @return Tweets in a structure like [lookup_tweets()]. -#' @examples -#' if (auth_has_default()) { -#' tw_thread <- tweet_threading("1461776330584956929") -#' tw_thread -#' } #' @export tweet_threading <- function(tw, traverse = c("backwards", "forwards"), verbose = FALSE) { diff --git a/R/user_id.R b/R/user_id.R index e4a71118..94ffa1b9 100644 --- a/R/user_id.R +++ b/R/user_id.R @@ -18,14 +18,6 @@ #' not static and may change over longer periods of time. #' #' @param x A character vector of Twitter screen names. -#' @examples -#' if (auth_has_default()) { -#' # Look up user with id -#' lookup_users("25594077") -#' -#' # Look up user with name 25594077 -#' lookup_users(as_screenname("123456")) -#' } #' @family users #' @rdname as_screenname #' @export diff --git a/R/users.R b/R/users.R index add0d92c..4f57c313 100644 --- a/R/users.R +++ b/R/users.R @@ -7,13 +7,9 @@ #' #' @examples #' -#' if (auth_has_default()) { +#' if (FALSE) { #' users <- c("twitter", "rladiesglobal", "_R_Foundation") #' users <- lookup_users(users) -#' users -#' -#' # latest tweet from each user -#' tweets_data(users) #' } #' #' @return A tibble of users data. diff --git a/man/as_screenname.Rd b/man/as_screenname.Rd index 4de7f87c..0c811888 100644 --- a/man/as_screenname.Rd +++ b/man/as_screenname.Rd @@ -27,15 +27,6 @@ tell rtweet that it's actually a screen name. Note that in general, you are best off using user ids; screen names are not static and may change over longer periods of time. } -\examples{ -if (auth_has_default()) { -# Look up user with id -lookup_users("25594077") - -# Look up user with name 25594077 -lookup_users(as_screenname("123456")) -} -} \seealso{ Other users: \code{\link{lists_subscribers}()}, diff --git a/man/clean_tweets.Rd b/man/clean_tweets.Rd index 3ecbe0cf..88939a81 100644 --- a/man/clean_tweets.Rd +++ b/man/clean_tweets.Rd @@ -17,14 +17,5 @@ A vector with the text without the entities selected \description{ Removes from the text, users mentions, hashtags, urls and media. Some urls or other text might remain if it is not recognized as an entity by -the API. -} -\examples{ -if (auth_has_default()) { -tweets <- search_tweets("weather") -tweets - -# tweets -clean_tweets(tweets) -} +the API. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } diff --git a/man/direct_messages.Rd b/man/direct_messages.Rd index b75da920..8a545105 100644 --- a/man/direct_messages.Rd +++ b/man/direct_messages.Rd @@ -65,16 +65,13 @@ A list with one element for each page of results. \description{ Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order. Includes detailed information -about the sender and recipient. +about the sender and recipient. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \examples{ \dontrun{ ## get my direct messages -dms <- direct_messages() - -## inspect data structure -str(dms) +direct_messages() } } diff --git a/man/direct_messages_received.Rd b/man/direct_messages_received.Rd index 0ba20f2a..4fa96ef9 100644 --- a/man/direct_messages_received.Rd +++ b/man/direct_messages_received.Rd @@ -43,16 +43,8 @@ this endpoint. ## get my direct messages dms <- direct_messages_received() - -## inspect data structure -str(dms) - ## get direct messages I've sent sdms <- direct_messages_sent() - -## inspect data structure -str(dms) - } } diff --git a/man/do_call_rbind.Rd b/man/do_call_rbind.Rd index 5206cbf9..ea6c2b4b 100644 --- a/man/do_call_rbind.Rd +++ b/man/do_call_rbind.Rd @@ -20,29 +20,6 @@ functions. } \description{ Row bind lists of tweets/users data whilst also preserving and binding -users/tweets attribute data. -} -\examples{ - -if (auth_has_default()) { - -## lapply through three different search queries -lrt <- lapply( - c("rstats OR tidyverse", "data science", "python"), - search_tweets, - n = 100 -) - -## convert list object into single parsed data rame -rt <- do_call_rbind(lrt) - -## preview tweets data -rt - -## preview users data -users_data(rt) - -} - +users/tweets attribute data. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \concept{parsing} diff --git a/man/entity.Rd b/man/entity.Rd index 34bc44ce..8f9ad203 100644 --- a/man/entity.Rd +++ b/man/entity.Rd @@ -24,17 +24,3 @@ Extract entities of the tweets linked to a tweet id. \details{ The position of where does this occur is not provided. } -\examples{ -if (auth_has_default()) { - statuses <- c( - "567053242429734913", - "266031293945503744", - "440322224407314432" - ) - - ## lookup tweets data for given statuses - tw <- lookup_tweets(statuses) - entity(tw, "urls") - -} -} diff --git a/man/get_favorites.Rd b/man/get_favorites.Rd index 8ca2d50a..37634555 100644 --- a/man/get_favorites.Rd +++ b/man/get_favorites.Rd @@ -67,18 +67,11 @@ A tibble with one row for each tweet. } \description{ Returns up to 3,000 tweets liked/favorited for each \code{user}. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \examples{ -if (auth_has_default()) { -# get likes for a single user -kfc <- get_favorites("KFC") -kfc -# get newer likes since last request -newer <- get_favorites("KFC", since_id = kfc) - -# get likes from multiple users -favs <- get_favorites(c("Lesdoggg", "pattonoswalt", "meganamram")) -favs +if (FALSE) { + get_favorites("KFC") } } \references{ diff --git a/man/get_followers.Rd b/man/get_followers.Rd index 32c9aa7f..f9fc94d8 100644 --- a/man/get_followers.Rd +++ b/man/get_followers.Rd @@ -68,16 +68,11 @@ followers and another one "to_id" with the user used as input. } \description{ Returns a list of user IDs for the accounts following specified -user. +user. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \examples{ -if (auth_has_default()) { +if (FALSE) { users <- get_followers("_R_Foundation") - users - - # use `cursor` to find the next "page" of results - more_users <- get_followers("_R_Foundation", cursor = users) - } } \references{ diff --git a/man/get_friends.Rd b/man/get_friends.Rd index 9b421418..ece450d2 100644 --- a/man/get_friends.Rd +++ b/man/get_friends.Rd @@ -69,7 +69,7 @@ user and "to_id" for accounts ID they follow. } \description{ Returns a list of user IDs for the accounts following BY one or -more specified users. +more specified users. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ Generally, you should not need to set \code{n} to more than 5,000 since Twitter @@ -81,9 +81,8 @@ If a user is protected the API will omit all requests so you'll need to find which user is protected. rtweet will warn you and the output will be \code{NA}. } \examples{ -if (auth_has_default()) { -users <- get_friends("ropensci") -users +if (FALSE) { + get_friends("ropensci") } } \references{ diff --git a/man/get_mentions.Rd b/man/get_mentions.Rd index 5d81da89..051047a5 100644 --- a/man/get_mentions.Rd +++ b/man/get_mentions.Rd @@ -69,16 +69,7 @@ Tibble of mentions data. Returns data on up to 200 of the most recent mentions (Tweets containing a users' screen_name) of the authenticating user. The timeline returned is the equivalent of the one seen when you view -your mentions on twitter.com. -} -\examples{ -if (auth_has_default()) { - tw <- get_mentions() - tw - - # newer mentions - get_mentions(since_id = tw) -} +your mentions on twitter.com. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/overview} diff --git a/man/get_timeline.Rd b/man/get_timeline.Rd index bbbba3ba..6add5c4f 100644 --- a/man/get_timeline.Rd +++ b/man/get_timeline.Rd @@ -94,30 +94,15 @@ A tbl data frame of tweets data with users data attribute. \code{get_timeline()} returns the timeline of any Twitter user (i.e. what they have tweeted). \code{get_my_timeline()} returns the home timeline for the authenticated user (i.e. the tweets you see when you log into Twitter). -} -\details{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} At most up to 3,200 of a user's most recent Tweets can be retrieved. -} -\examples{ -if (auth_has_default()) { -tw <- get_timeline("_R_Foundation") -tw - -# get tweets that arrived since the last request -get_timeline("_R_Foundation", since_id = tw) -# get earlier tweets -get_timeline("_R_Foundation", max_id = tw) - -# get timelines for multiple users -tw <- get_timeline(c("_R_Foundation", "rOpenSci", "Bioconductor")) -tw -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/overview} } \seealso{ +\code{\link[=user_timeline]{user_timeline()}} + Other tweets: \code{\link{get_favorites}()}, \code{\link{get_mentions}()}, diff --git a/man/get_trends.Rd b/man/get_trends.Rd index 3c7d44b5..1c369952 100644 --- a/man/get_trends.Rd +++ b/man/get_trends.Rd @@ -47,39 +47,7 @@ Twitter API.} Tibble data frame of trends data for a given geographical area. } \description{ -Get Twitter trends data. -} -\examples{ -if (auth_has_default()) { - -## Retrieve available trends -trends <- trends_available() -trends - -## Store WOEID for Worldwide trends -worldwide <- trends$woeid[grep("world", trends$name, ignore.case = TRUE)[1]] - -## Retrieve worldwide trends datadata -ww_trends <- get_trends(worldwide) - -## Preview trends data -ww_trends - -## Retrieve trends data using latitude, longitude near New York City -nyc_trends <- get_trends(lat = 40.7, lng = -74.0) - -## should be same result if lat/long supplied as first argument -nyc_trends <- get_trends(c(40.7, -74.0)) - -## Preview trends data -nyc_trends - -## Provide a city or location name using a regular expression string to -## have the function internals do the WOEID lookup/matching for you -(luk <- get_trends("london")) - -} - +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \seealso{ Other trends: diff --git a/man/ids.Rd b/man/ids.Rd index f57a681f..9f282335 100644 --- a/man/ids.Rd +++ b/man/ids.Rd @@ -15,13 +15,3 @@ ids(x, ...) Extract the ids of the rtweet data if present. Depending on the object type it returns either users ids, tweet ids or rules ids. } -\examples{ -if (auth_has_default()) { - users <- lookup_users(c("twitter", "rladiesglobal", "_R_Foundation")) - ids(users) - followers <- get_followers("_R_Foundation") - head(ids(followers)) - friends <- get_friends("_R_Foundation") - head(ids(friends)) -} -} diff --git a/man/lat_lng.Rd b/man/lat_lng.Rd index 53a2ef2c..9e1f9562 100644 --- a/man/lat_lng.Rd +++ b/man/lat_lng.Rd @@ -31,7 +31,7 @@ and longitude vars. } \description{ Appends parsed Twitter data with latitude and longitude variables -using all available geolocation information. +using all available geolocation information. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ On occasion values may appear to be outliers given a @@ -41,19 +41,6 @@ tweets returned a large bounding box that overlapped with the area of interest. This function converts boxes into their geographical midpoints, which works well in the vast majority of cases, but sometimes includes an otherwise puzzling result. -} -\examples{ - -if (auth_has_default()) { - -## stream tweets sent from the US -rt <- search_tweets(geocode = lookup_coords("usa")) - -## use lat_lng to recover full information geolocation data -rtl_loc <- lat_lng(rt) -rtl_loc -} - } \seealso{ Other geo: diff --git a/man/links.Rd b/man/links.Rd index b766e90f..f85f6eb5 100644 --- a/man/links.Rd +++ b/man/links.Rd @@ -15,13 +15,3 @@ links(x, ...) create the links from the rtweet data present. Depending on the object type it returns either users links, tweet links or rules links. } -\examples{ -if (auth_has_default()) { - users <- lookup_users(c("twitter", "rladiesglobal", "_R_Foundation")) - links(users) - followers <- get_followers("_R_Foundation") - head(links(followers)) - friends <- get_friends("_R_Foundation") - head(links(friends)) -} -} diff --git a/man/lists_members.Rd b/man/lists_members.Rd index d0d441c3..4b74af98 100644 --- a/man/lists_members.Rd +++ b/man/lists_members.Rd @@ -72,20 +72,6 @@ Twitter API.} } \description{ Get Twitter list members (users on a given list). -} -\examples{ -if (auth_has_default()) { - -## get list members for a list of rstats experts using list_id -(rstats <- lists_members("1260528710559694850")) - -## get list members for an rstats list using list topic slug -## list owner's screen name -rstats <- lists_members(slug = "r-people", owner_user = "Lluis_Revilla") -rstats - -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-members} diff --git a/man/lists_memberships.Rd b/man/lists_memberships.Rd index ba29c12c..6ea1998a 100644 --- a/man/lists_memberships.Rd +++ b/man/lists_memberships.Rd @@ -71,18 +71,6 @@ progress?} Due to deleted or removed lists, the returned number of memberships is often less than the provided n value. This is a reflection of the API and not a unique quirk of rtweet. -} -\examples{ -if (auth_has_default()) { - -## get up to 1000 Twitter lists that include Nate Silver -R_foundation <- lists_memberships("_R_Foundation", n = 1000) - -## view data -R_foundation - -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships} diff --git a/man/lists_statuses.Rd b/man/lists_statuses.Rd index 9021201b..68c17516 100644 --- a/man/lists_statuses.Rd +++ b/man/lists_statuses.Rd @@ -84,12 +84,6 @@ data \description{ Get a timeline of tweets authored by members of a specified list. } -\examples{ -if (auth_has_default()) { - (rladies <- lists_statuses(list_id = "839186302968848384")) - (rladies <- lists_statuses(slug = "rladies1", owner_user = "RLadiesGlobal")) -} -} \seealso{ Other lists: \code{\link{lists_members}()}, diff --git a/man/lists_subscribers.Rd b/man/lists_subscribers.Rd index 6b10ab31..1e5b69fc 100644 --- a/man/lists_subscribers.Rd +++ b/man/lists_subscribers.Rd @@ -64,13 +64,6 @@ default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ Get subscribers of a specified list. -} -\examples{ -if (auth_has_default()) { - ## get subscribers of rladies list - rstats <- lists_subscribers(slug = "rladies1", owner_user = "rladiesglobal") -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers} diff --git a/man/lists_subscriptions.Rd b/man/lists_subscriptions.Rd index 797c8480..7cd251c6 100644 --- a/man/lists_subscriptions.Rd +++ b/man/lists_subscriptions.Rd @@ -63,13 +63,6 @@ default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} \description{ Get list subscriptions of a given user but does not include the user's own lists. -} -\examples{ -if (auth_has_default()) { -## get ropensci subscriptions -rstats <- lists_subscriptions(user = "rladiesglobal", n = 1000) -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-subscriptions} diff --git a/man/lists_users.Rd b/man/lists_users.Rd index 0bd9414f..c28daba1 100644 --- a/man/lists_users.Rd +++ b/man/lists_users.Rd @@ -27,15 +27,6 @@ data } \description{ Get all lists a specified user subscribes to, including their own. -} -\examples{ -if (auth_has_default()) { - -## get lists subscribed to by R_Foundation -lists_users("ropensci") - -} - } \seealso{ Other lists: diff --git a/man/lookup_coords.Rd b/man/lookup_coords.Rd index 749ef5da..92593b58 100644 --- a/man/lookup_coords.Rd +++ b/man/lookup_coords.Rd @@ -58,12 +58,6 @@ usa <- lookup_coords("usa") lnd <- lookup_coords("london") bz <- lookup_coords("brazil") -## pass a returned coords object to search_tweets -bztw <- search_tweets(geocode = bz) - -## or stream tweets -ustw <- stream_tweets(usa, timeout = 10) - } } diff --git a/man/lookup_tweets.Rd b/man/lookup_tweets.Rd index 2688aedd..148fbb7f 100644 --- a/man/lookup_tweets.Rd +++ b/man/lookup_tweets.Rd @@ -43,26 +43,14 @@ progress?} A tibble of tweets data. } \description{ -Get tweets data for given statuses (status IDs). -} -\examples{ - -if (auth_has_default()) { - statuses <- c( - "567053242429734913", - "266031293945503744", - "440322224407314432" - ) - - ## lookup tweets data for given statuses - tw <- lookup_tweets(statuses) - tw -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-lookup} } \seealso{ +\code{\link[=tweet_search_recent]{tweet_search_recent()}} + Other tweets: \code{\link{get_favorites}()}, \code{\link{get_mentions}()}, diff --git a/man/lookup_users.Rd b/man/lookup_users.Rd index 0d892dd4..7323d103 100644 --- a/man/lookup_users.Rd +++ b/man/lookup_users.Rd @@ -46,13 +46,9 @@ Get Twitter users data for given users (user IDs or screen names). } \examples{ -if (auth_has_default()) { +if (FALSE) { users <- c("twitter", "rladiesglobal", "_R_Foundation") users <- lookup_users(users) - users - - # latest tweet from each user - tweets_data(users) } } diff --git a/man/max_id.Rd b/man/max_id.Rd index b6a7b85f..24b5dd0a 100644 --- a/man/max_id.Rd +++ b/man/max_id.Rd @@ -13,16 +13,4 @@ max_id(x) These internal helpers extract the ids passed on to the \code{max_id} and \code{since_id} arguments to functions that use \code{\link[=TWIT_paginate_max_id]{TWIT_paginate_max_id()}}. } -\examples{ -if (auth_has_default()) { -tw <- search_tweets("#rstats") - -# retrieve older tweets -older <- search_tweets("#rstats", max_id = tw) -even_older <- search_tweets("#rstats", max_id = older) - -# retrieve newer tweets -newer <- search_tweets("#rstats", since_id = tw) -} -} \keyword{internal} diff --git a/man/network_data.Rd b/man/network_data.Rd index 93ae2dda..ddc3643f 100644 --- a/man/network_data.Rd +++ b/man/network_data.Rd @@ -33,31 +33,7 @@ various network classes. } \details{ Retrieve data to know which users are connected to which users. -} -\examples{ -if (auth_has_default()) { - ## search for #rstats tweets - rstats <- search_tweets("#rstats", n = 200) - - ## create from-to data frame representing retweet/mention/reply connections - rstats_net <- network_data(rstats, c("retweet","mention","reply")) - - ## view edge data frame - rstats_net - - ## view user_id->screen_name index - attr(rstats_net, "idsn") - - ## if igraph is installed... - if (requireNamespace("igraph", quietly = TRUE)) { - - ## (1) convert directly to graph object representing semantic network - rstats_net <- network_graph(rstats) - - ## (2) plot graph via igraph.plotting - plot(rstats_net) - } -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \seealso{ network_graph diff --git a/man/next_cursor.Rd b/man/next_cursor.Rd index deaa66a5..7c7bc002 100644 --- a/man/next_cursor.Rd +++ b/man/next_cursor.Rd @@ -13,10 +13,4 @@ since_id(x) This internal helper extracts the cursor from the object passed to the \code{cursor} argument of the functions that use \code{\link[=TWIT_paginate_cursor]{TWIT_paginate_cursor()}}. } -\examples{ -if (auth_has_default()) { -page1 <- get_followers("_R_Foundation") -page2 <- get_followers("_R_Foundation", cursor = page1) -} -} \keyword{internal} diff --git a/man/parse_stream.Rd b/man/parse_stream.Rd index b1448c0b..3fc4e61a 100644 --- a/man/parse_stream.Rd +++ b/man/parse_stream.Rd @@ -14,6 +14,7 @@ parse_stream(path, ...) } \description{ Converts Twitter stream data (JSON file) into parsed data frame. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \examples{ \dontrun{ diff --git a/man/post_destroy.Rd b/man/post_destroy.Rd index 740b547e..3ccb835c 100644 --- a/man/post_destroy.Rd +++ b/man/post_destroy.Rd @@ -16,14 +16,11 @@ a single API call. In many cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ -Deletes a status of user's profile. -} -\examples{ -if (auth_has_default()) { - pt <- post_tweet("Running #rtweet examples") - post_destroy(ids(pt)) -} +Deletes a status of user's profile. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-destroy-id} } +\seealso{ +\code{\link[=tweet_delete]{tweet_delete()}} +} diff --git a/man/post_favorite.Rd b/man/post_favorite.Rd index 1bc32081..ddbe6928 100644 --- a/man/post_favorite.Rd +++ b/man/post_favorite.Rd @@ -27,13 +27,7 @@ a single API call. In many cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ -Favorites target status id. -} -\examples{ -if (auth_has_default()) { - rt <- search_tweets("#rstats", n = 1) - post_favorite(rt$id_str) -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ Create: \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create} diff --git a/man/post_follow.Rd b/man/post_follow.Rd index 0c1798f2..f9dacc45 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -44,13 +44,7 @@ a single API call. In many cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ -Follows target Twitter user. -} -\examples{ -if (auth_has_default()) { - post_follow("_R_Foundation") - post_follow("rtweet", mute = TRUE) # Mute -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ Update: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-update} diff --git a/man/post_list.Rd b/man/post_list.Rd index dbcf0d4e..b6559ce8 100644 --- a/man/post_list.Rd +++ b/man/post_list.Rd @@ -41,46 +41,7 @@ default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} Response object from HTTP request. } \description{ -Create, add users, and destroy Twitter lists -} -\examples{ -\dontrun{ - -## R related Twitter accounts -users <- c("_R_Foundation", "R_dev_news", "rweekly_live", "RConsortium", "rstats4ds", - "icymi_r", "rstatstweet", "RLadiesGlobal") - -## create r-accounts list with 8 total users -(r_lst <- post_list(users, - "r-accounts", description = "R related accounts")) - -## view list in browser at https://twitter.com//lists/r-accounts - -## search for more rstats users -r_users <- search_users("rstats", n = 200) - -## filter and select more users to add to list -more_users <- r_users$screen_name[r_users$verified] - -## add more users to list- note: can only add up to 100 at a time -post_list(users = more_users, slug = "r-accounts") - -## view updated list in browser (should be around 100 users) -## view list in browser at https://twitter.com//lists/r-accounts - -drop_users <- "icymi_r" - -## drop these users from the R list -post_list(users = drop_users, slug = "r-accounts", - destroy = TRUE) - -## view updated list in browser (should be around 100 users) -## view list in browser at https://twitter.com//lists/r-accounts - -## delete list entirely -post_list(slug = "r-accounts", destroy = TRUE) - -} +Create, add users, and destroy Twitter lists. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ Create: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-create} diff --git a/man/post_tweet.Rd b/man/post_tweet.Rd index 3cb3ac29..6c52f502 100644 --- a/man/post_tweet.Rd +++ b/man/post_tweet.Rd @@ -68,45 +68,7 @@ been sent from. Value should be TRUE or FALSE. This parameter would apply only if you have provided a valid \code{lat/long} pair of valid values.} } \description{ -Posts status update to user's Twitter account -} -\examples{ -if (auth_has_default()) { -## generate data to make/save plot (as a .png file) -x <- rnorm(300) -y <- x + rnorm(300, 0, .75) -col <- c(rep("#002244aa", 50), rep("#440000aa", 50)) -bg <- c(rep("#6699ffaa", 50), rep("#dd6666aa", 50)) - -## create temporary file name -tmp <- tempfile(fileext = ".png") - -## save as png -png(tmp, 6, 6, "in", res = 127.5) -par(tcl = -.15, family = "Inconsolata", - font.main = 2, bty = "n", xaxt = "l", yaxt = "l", - bg = "#f0f0f0", mar = c(3, 3, 2, 1.5)) -plot(x, y, xlab = NULL, ylab = NULL, pch = 21, cex = 1, - bg = bg, col = col, - main = "This image was uploaded by rtweet") -grid(8, lwd = .15, lty = 2, col = "#00000088") -dev.off() - -## post tweet with media attachment -post_tweet("a tweet with media attachment", media = tmp, - media_alt_text = "Random points example of rtweet::post_tweet. - rtweet requires alt text with all media") - -# example of replying within a thread -## first post -pt <- post_tweet(status="first in a thread") - -reply_id <- ids(pt) - -## post reply -post_tweet("second in the thread", - in_reply_to_status_id = reply_id) -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ Tweet: \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-update} @@ -115,6 +77,8 @@ Media: \url{https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-me Alt-text: \url{https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-metadata-create} } \seealso{ +\code{\link[=tweet_post]{tweet_post()}} + Other post: \code{\link{post_favorite}()}, \code{\link{post_follow}()}, diff --git a/man/rate_limit.Rd b/man/rate_limit.Rd index c6ce259a..a401875f 100644 --- a/man/rate_limit.Rd +++ b/man/rate_limit.Rd @@ -34,10 +34,8 @@ You should not need to use these function in the usual operation of rtweet because all paginated functions will wait on your behalf if you set \code{retryonratelimit = TRUE}. } -\examples{ -if (auth_has_default()) { -rate_limit() -} +\details{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status} diff --git a/man/read_twitter_csv.Rd b/man/read_twitter_csv.Rd index 7972230a..ccde4200 100644 --- a/man/read_twitter_csv.Rd +++ b/man/read_twitter_csv.Rd @@ -18,15 +18,7 @@ A tbl data frame of Twitter data } \description{ Reads Twitter data that was previously saved as a CSV file. -} -\examples{ - -\dontrun{ - -## read in data.csv -rt <- read_twitter_csv("data.csv") - -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \seealso{ Other datafiles: diff --git a/man/rtweet_client.Rd b/man/rtweet_client.Rd index 0cfd7573..93119041 100644 --- a/man/rtweet_client.Rd +++ b/man/rtweet_client.Rd @@ -22,10 +22,12 @@ Leave \code{NULL} to allow everything or choose yours with \code{set_scopes()}.} Set up your client mechanism for the Twitter API. } \examples{ +\donttest{ if (interactive()) { rtweet_client() } } +} \seealso{ scopes } diff --git a/man/rtweet_user.Rd b/man/rtweet_user.Rd index c38e94f9..23fa6ab9 100644 --- a/man/rtweet_user.Rd +++ b/man/rtweet_user.Rd @@ -87,8 +87,6 @@ since the default behaviour is to use ask_pass that if possible uses \examples{ \dontrun{ -rtweet_user() -rtweet_bot() rtweet_app() } } diff --git a/man/search_fullarchive.Rd b/man/search_fullarchive.Rd index f6221190..18797f96 100644 --- a/man/search_fullarchive.Rd +++ b/man/search_fullarchive.Rd @@ -90,6 +90,7 @@ See the info provided by Twitter and the "Developer Account" section. } \details{ Note: The \code{env_name} must match the ones you set up for the token you are using. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \section{Developer Account}{ @@ -154,19 +155,7 @@ followed by a word or quoted phrase (if appropriate)–e.g.,} \code{lang:en} } } -\examples{ - -\dontrun{ -## search fullarchive for up to 300 rstats tweets sent in Jan 2014 -rt <- search_fullarchive("#rstats", n = 300, env_name = "SetYourLabel", - fromDate = "201401010000", toDate = "201401312359") - -toDate <- format(Sys.time() - 60 * 60 * 24 * 7, "\%Y\%m\%d\%H\%M") - -## search 30day for up to 300 rstats tweets sent before the last week -rt <- search_30day("#rstats", n = 300, - env_name = "SetYourLabel", toDate = toDate) -} - +\seealso{ +\code{\link[=tweet_search_recent]{tweet_search_recent()}}, \code{\link[=tweet_search_all]{tweet_search_all()}} } \concept{premium endpoints} diff --git a/man/search_tweets.Rd b/man/search_tweets.Rd index d3868f99..b8891044 100644 --- a/man/search_tweets.Rd +++ b/man/search_tweets.Rd @@ -120,10 +120,11 @@ A tbl data frame with additional "query" column. } \description{ Returns Twitter statuses matching a user provided search -query. ONLY RETURNS DATA FROM THE PAST 6-9 DAYS. +query. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} search_tweets2 Passes all arguments to search_tweets. Returns data from one OR MORE search queries. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ Twitter API documentation recommends limiting searches to @@ -132,48 +133,15 @@ errors preventing recovery of information related to the query. It should also be noted Twitter's search API does not consist of an index of all Tweets. At the time of searching, the search API index includes between only 6-9 days of Tweets. -} -\examples{ -if (auth_has_default()) { -tweets <- search_tweets("weather") -tweets - -# data about the users who made those tweets -users_data(tweets) - -# Retrieve all the tweets made since the previous request -# (there might not be any if people aren't tweeting about the weather) -newer <- search_tweets("weather", since_id = tweets) -# Retrieve tweets made before the previous request -older <- search_tweets("weather", max_id = tweets) - -# Restrict to English only, and ignore retweets -tweets2 <- search_tweets("weather", lang = "en", include_rts = FALSE) -} -if (auth_has_default()) { - -## search using multiple queries -st2 <- search_tweets2( - c("\"data science\"", "rstats OR python"), - n = 500 -) - -## preview tweets data -st2 - -## preview users data -users_data(st2) - -## check breakdown of results by search query -table(st2$query) - -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets} } \seealso{ +\code{\link[=tweet_search_recent]{tweet_search_recent()}}, \code{\link[=tweet_search_all]{tweet_search_all()}} + +\code{\link[=tweet_search_recent]{tweet_search_recent()}} + Other tweets: \code{\link{get_favorites}()}, \code{\link{get_mentions}()}, diff --git a/man/search_users.Rd b/man/search_users.Rd index dbf729b4..9b0eee31 100644 --- a/man/search_users.Rd +++ b/man/search_users.Rd @@ -41,22 +41,14 @@ Data frame with one row for each matching user. } \description{ Search for Twitter users. The Twitter API limits the results to at most -1,000 users. -} -\examples{ -if (auth_has_default()) { -users <- search_users("#rstats", n = 300) -users - -# latest tweet from each user -tweets_data(users) -} - +1,000 users. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-users-search} } \seealso{ +\code{\link[=user_search]{user_search()}} + Other users: \code{\link{as_screenname}()}, \code{\link{lists_subscribers}()}, diff --git a/man/stream_tweets.Rd b/man/stream_tweets.Rd index 361ce1a4..78bda90a 100644 --- a/man/stream_tweets.Rd +++ b/man/stream_tweets.Rd @@ -66,21 +66,8 @@ Streams public statuses to a file via one of the following four methods: Learn more in \code{vignette("stream", package = "rtweet")} } -\examples{ -\dontrun{ -# stream tweets mentioning "#rstats" for 10 seconds -rstats1 <- stream_tweets("#rstats", timeout = 10, file_name = "rstats.json") -rstats1 - -# Download another 10s worth of data to the same file -rstats2 <- stream_tweets("#rstats", timeout = 10, file_name = "rstats.json", - append = TRUE) - -# stream tweets about continental USA for 10 seconds -usa <- stream_tweets(location = lookup_coords("usa"), file_name = "usa.json", - timeout = 10) - -} +\details{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ They were removed from the website. @@ -88,5 +75,5 @@ They were removed from the website. The webpages describing how it used to work were removed. } \seealso{ -\code{\link[=parse_stream]{parse_stream()}}. +\code{\link[=filtered_stream]{filtered_stream()}}. } diff --git a/man/trends_available.Rd b/man/trends_available.Rd index 458bab67..e4aab285 100644 --- a/man/trends_available.Rd +++ b/man/trends_available.Rd @@ -20,16 +20,7 @@ Data frame with WOEID column. WOEID is a Yahoo! Where On Earth ID. } \description{ -Available Twitter trends along with associated WOEID. -} -\examples{ -if (auth_has_default()) { -## Retrieve available trends -trends <- trends_available() -trends - -} - +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/v1/trends/locations-with-trending-topics/api-reference/get-trends-available} diff --git a/man/ts_data.Rd b/man/ts_data.Rd index 13b05b31..d2c9caaf 100644 --- a/man/ts_data.Rd +++ b/man/ts_data.Rd @@ -24,22 +24,6 @@ Data frame with time, n, and grouping column if applicable. } \description{ Returns data containing the frequency of tweets over a specified -interval of time. -} -\examples{ -if (auth_has_default()) { - -## handles of women senators -orgs <- c("_R_Foundation", "ropensci") - -## get timelines for each -orgs_tml <- get_timeline(orgs, n = 100) - -## get single time series for tweets -ts_data(orgs_tml) - -## using weekly intervals -ts_data(orgs_tml, "weeks") -} - +interval of time. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } +\keyword{internal} diff --git a/man/ts_plot.Rd b/man/ts_plot.Rd index 3fe10f85..d7bb0897 100644 --- a/man/ts_plot.Rd +++ b/man/ts_plot.Rd @@ -29,19 +29,7 @@ installed then a \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} plot object. } \description{ Creates a ggplot2 plot of the frequency of tweets over a specified -interval of time. -} -\examples{ - -if (auth_has_default()) { -## search for tweets containing "rstats" -rt <- search_tweets("rstats", n = 100) - -## plot frequency in 1 min intervals -ts_plot(rt, "mins") - -## examine all Twitter activity using weekly intervals -ts_plot(rt, "hours") -} +interval of time. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \concept{ts_data} +\keyword{internal} diff --git a/man/tweet_delete.Rd b/man/tweet_delete.Rd index 9bb4618b..841d8f9e 100644 --- a/man/tweet_delete.Rd +++ b/man/tweet_delete.Rd @@ -17,14 +17,6 @@ created via \code{\link[=rtweet_oauth2]{rtweet_oauth2()}}) or a bearer token (ca } \description{ Will delete a tweet -} -\examples{ -if (FALSE) { - # It requires Oauth authentication - tp <- tweet_post("Running examples of #rtweet") - td <- tweet_delete(tp$id) -} - } \references{ \url{https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id} diff --git a/man/tweet_quoted.Rd b/man/tweet_quoted.Rd index a8c569ae..532dd697 100644 --- a/man/tweet_quoted.Rd +++ b/man/tweet_quoted.Rd @@ -50,6 +50,3 @@ if (FALSE){ \references{ One tweet: \url{https://developer.twitter.com/en/docs/twitter-api/tweets/quote-tweets/api-reference/get-tweets-id-quote_tweets} } -\seealso{ -\code{\link[=lookup_tweets]{lookup_tweets()}} \code{\link[=tweet_get]{tweet_get()}} -} diff --git a/man/tweet_shot.Rd b/man/tweet_shot.Rd index 283c7274..ed45581f 100644 --- a/man/tweet_shot.Rd +++ b/man/tweet_shot.Rd @@ -23,6 +23,7 @@ own image manipulation.} Provide a status id or a full Twitter link to a tweet and this function will capture an image of the tweet --- or tweet + thread (if there are Twitter-linked replies) --- from the mobile version of said tweet/thread. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ For this to work, you will need to ensure the packages in \verb{Suggests:} are diff --git a/man/tweet_threading.Rd b/man/tweet_threading.Rd index 218c7196..12610a17 100644 --- a/man/tweet_threading.Rd +++ b/man/tweet_threading.Rd @@ -23,6 +23,7 @@ Return all statuses that are part of a thread (Replies from a user to their own tweets). By default the function traverses first backwards from the origin status_id of the thread up to the root, then checks if there are any child statuses that were posted after the origin status. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ The backwards method looks up the tweet which is replying to, so it works if @@ -31,9 +32,3 @@ starting from the last tweet of the thread. The forwards method looks for newer replies to the tweet provided. If the tweet doesn't have a reply it won't be able to find anything. The forwards method is limited by the timeline API (See \code{\link[=get_timeline]{get_timeline()}}). } -\examples{ -if (auth_has_default()) { -tw_thread <- tweet_threading("1461776330584956929") -tw_thread -} -} diff --git a/man/user_block.Rd b/man/user_block.Rd index a1d77ca9..291eb75d 100644 --- a/man/user_block.Rd +++ b/man/user_block.Rd @@ -23,13 +23,7 @@ default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} \description{ \code{user_block(...)} blocks or unblocks a target twitter user. \code{user_unblock(...)} is synonymous to \code{user_block(..., unblock=TRUE)}. -} -\examples{ -if (auth_has_default()) { - user_block("rtweet") - user_unblock("rtweet") - user_block("rtweet", unblock=TRUE) #<-same as the above -} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \references{ Block: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create} diff --git a/man/users_data.Rd b/man/users_data.Rd index 076e0fe2..4e6dc7e3 100644 --- a/man/users_data.Rd +++ b/man/users_data.Rd @@ -25,16 +25,3 @@ Showing these additional columns would clutter the default display, so rtweet instead stores in special attributes and allows you to show them with the \code{user_data()} and \code{tweets_data()} helpers. } -\examples{ -if (auth_has_default()) { - # find users from tweets - tweets <- search_tweets("r") - users_data(tweets) - full_search <- cbind(tweets, users_data(tweets)) - - # from tweets from users - users <- search_users("r") - tweets_data(users) - full_users <- cbind(users, tweets_data(users)) -} -} diff --git a/tests/testthat/_snaps/post-tweet.md b/tests/testthat/_snaps/post-tweet.md deleted file mode 100644 index fcf4088f..00000000 --- a/tests/testthat/_snaps/post-tweet.md +++ /dev/null @@ -1,29 +0,0 @@ -# Check geo-related inputs for post_tweet - - Code - msg <- paste("test geolocated error", Sys.time()) - post_tweet(msg, lat = "x", long = 0) - Condition - Error in `post_tweet()`: - ! `lat` must be numeric. - Code - post_tweet(msg, lat = 0, long = "x") - Condition - Error in `post_tweet()`: - ! `long` must be numeric. - Code - post_tweet(msg, lat = 91, long = 0) - Condition - Error in `post_tweet()`: - ! `lat` must be between -90 and 90 degrees. - Code - post_tweet(msg, lat = 0, long = 181) - Condition - Error in `post_tweet()`: - ! `long` must be between -180 and 180 degrees. - Code - post_tweet(msg, lat = 0, long = 0, display_coordinates = "error") - Condition - Error in `post_tweet()`: - ! `display_coordinates` must be TRUE/FALSE. - diff --git a/tests/testthat/_snaps/user_id.md b/tests/testthat/_snaps/user_id.md deleted file mode 100644 index dab6cdae..00000000 --- a/tests/testthat/_snaps/user_id.md +++ /dev/null @@ -1,8 +0,0 @@ -# screen_name has print and [ methods - - Code - x - Output - - [1] "123456" -