#' Extracts all hashtags included in the input tweet data list
#'
#' @param tweets A vector of tweets
#'
#' @return Vector of hashtags
#' @export
#'
#' @examples
#' tweets <- c(
#' "Make America Great Again #DonaldTrump"
#' )
#' extract_hashtags(tweets)
#'
extract_hashtags <- function(tweets) {
if(!is.character(tweets)) {
stop("input should be a character vector")
}
output_vec <- stringr::str_extract_all(tweets, "#\\S+")
output_vec <- stringr::str_remove_all(unlist(output_vec), "#")
output_vec
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.