as_tweet_sf: Build an 'sf' Object of Tweets

Description Usage Arguments Value Author(s) Examples

View source: R/geo.R

Description

Build an sf Object of Tweets

Usage

1
2
3
4
5
6
7
8
as_tweet_sf(
  tweet_df,
  geom_col = c("bbox_coords", "quoted_bbox_coords", "retweet_bbox_coords", "geo_coords",
    "all"),
  combine = TRUE,
  as_tibble = tweetio_as_tibble(),
  ...
)

Arguments

tweet_df

A data frame of tweets, as obtained by read_tweets() or one of {rtweet}'s collection functions, e.g. rtweet::search_tweets().

geom_col

Which column to use as the active geometry column in result: "bbox_coords", "quoted_bbox_coords","retweet_bbox_coords", "geo_coords", or "all".

combine

logical(1L), Default: TRUE. Whether to row-bind all geometries into a single sf::st_sf() object. If FALSE, a list() of sf::st_sf() objects are returned.

as_tibble

<logical>, Default: tweetio_as_tibble(). Whether a tibble::tibble() should be returned. Ignored if the {tibble} package is not installed.

...

Arguments passed to or from other methods.

Value

sf::st_sf(), or list() of sf::st_sf() objects if combine = FALSE

Author(s)

Brendan Knapp brendan.g.knapp@nps.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
path_to_tweet_file <- example_tweet_file()

tweet_df <- read_tweets(file_path = path_to_tweet_file)

bbox_coords <- as_tweet_sf(tweet_df)

rwtweet_bbox_cooords <- as_tweet_sf(tweet_df, geom_col = "retweet_bbox_coords")

tweet_sf <- as_tweet_sf(tweet_df, geom_col = "all", as_tibble = TRUE)

tweet_sf[, c("created_at", "text", "which_geom", "geometry")]

knapply/tweetio documentation built on Dec. 22, 2020, 7:15 p.m.