Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
Reorder exact phrase parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarrie committed Oct 18, 2021
1 parent 2dc53ff commit 16eaf94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions R/build_queryv2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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:"))
Expand All @@ -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 = " "))
}
Expand Down
6 changes: 3 additions & 3 deletions man/build_query.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 16eaf94

Please sign in to comment.