diff --git a/R/build_queryv2.R b/R/build_queryv2.R index 789a242..88c9a59 100644 --- a/R/build_queryv2.R +++ b/R/build_queryv2.R @@ -9,10 +9,10 @@ #' a character object query string to be input as query parameter to \code{\link{get_all_tweets}}. #' #' @param query string or character vector, search query or queries +#' @param exact_phrase If `TRUE`, only tweets will be returned matching the exact phrase #' @param users string or character vector, user handles to collect tweets from the specified users #' @param reply_to string or character vector, user handles to collect replies to the specified users #' @param retweets_of string or character vector, user handles to collects retweets of tweets by the specified users -#' @param exact_phrase If `TRUE`, only tweets will be returned matching the exact phrase #' @param exclude string or character vector, tweets containing the keyword(s) will be excluded #' #' @param is_retweet If `TRUE`, only retweets will be returned; if `FALSE`, retweets will be excluded; if `NULL`, both retweets and other tweet types will be returned. @@ -59,10 +59,10 @@ #' @importFrom utils menu #' build_query <- function(query = NULL, + exact_phrase = NULL, users = NULL, reply_to = NULL, retweets_of = NULL, - exact_phrase = NULL, exclude = NULL, is_retweet = NULL, is_reply = NULL, @@ -88,7 +88,10 @@ build_query <- function(query = NULL, if(isTRUE(length(query) >1)) { query <- paste("(",paste(query, collapse = " OR "),")", sep = "") } - + + if(isTRUE(exact_phrase)){ + query <- paste0("\"", query, "\"") + } if(!is.null(users)){ query <- paste(query, add_query_prefix(users, "from:")) @@ -102,10 +105,6 @@ build_query <- function(query = NULL, query <- paste(query, add_query_prefix(retweets_of, "retweets_of:")) } - if(isTRUE(exact_phrase)){ - query <- paste0("\"", query, "\"") - } - if(!is.null(exclude)) { query <- paste(query, paste("-", exclude, sep = "", collapse = " ")) } diff --git a/man/build_query.Rd b/man/build_query.Rd index 0ec56ed..3877196 100644 --- a/man/build_query.Rd +++ b/man/build_query.Rd @@ -6,10 +6,10 @@ \usage{ build_query( query = NULL, + exact_phrase = NULL, users = NULL, reply_to = NULL, retweets_of = NULL, - exact_phrase = NULL, exclude = NULL, is_retweet = NULL, is_reply = NULL, @@ -36,14 +36,14 @@ build_query( \arguments{ \item{query}{string or character vector, search query or queries} +\item{exact_phrase}{If \code{TRUE}, only tweets will be returned matching the exact phrase} + \item{users}{string or character vector, user handles to collect tweets from the specified users} \item{reply_to}{string or character vector, user handles to collect replies to the specified users} \item{retweets_of}{string or character vector, user handles to collects retweets of tweets by the specified users} -\item{exact_phrase}{If \code{TRUE}, only tweets will be returned matching the exact phrase} - \item{exclude}{string or character vector, tweets containing the keyword(s) will be excluded} \item{is_retweet}{If \code{TRUE}, only retweets will be returned; if \code{FALSE}, retweets will be excluded; if \code{NULL}, both retweets and other tweet types will be returned.}