Skip to contents

Introduction

When trying to solve a problem, part of the process is to research what attempts have been made by others. The most common form of research is to query a search portal. One downside to this approach is that each search portal has its own set of operators or query phrasing that will yield relevant content. As a result, those that have domain knowledge are able to format the search query in a way that is better. Still many queries are not constrained enough to the programming language being used. The goal of searcher is to attempt to address both needs by providing a convenient pre-specified search interface that tailors the results to R.

Usage

To begin using searcher, first install the package from CRAN.

# Install the searcher package if not already installed
install.packages("searcher")

Once installed, searching with searcher is done by using one or more of the search_*() functions. To access these functions, either use a namespace function call of searcher::search_*() or load the searcher package and, then, call the function.

# Loads the searcher package
library("searcher")

# Searches using Google for `tips`
search_google("tips")

Search Operators

Within the searcher package, each search_*() function has the parameter of rlang = TRUE. By default, this enforces a search that guarantees R-specific results. If rlang = FALSE, then the results are generalized.

  • Search Engines
    • All search engines affix "r programming" to the end of the query to constrain the results to be R-specific.
    • "r programming" was selected because it performed best when compared to "rlang", "rstats", and "r language" on Google Trends.
  • Community Sites
  • Code Repositories

General Search Tips

To improve your R-related search query, it has been suggested to use:

  • "r how to do <x>"
    • "r how to remove legends in ggplot"
    • This is a baseline search query.
  • "<package name> <problem>"
    • "ggplot2 fix x-axis labels."
    • If the package is R-specific, it may help dropping r and instead focusing on the package name at the start of the query.
  • "r <package-name> <problem> <year> site:<specific-site>
    • "r ggplot2 center graph title 2018 site:stackoverflow.com
    • By specifying the package name, a year, and target site the “freshest” solution will likely be found.

Suggestions here were pooled from discussion on rOpenSci’s slack with Steph Locke and Robert Mitchell.

Search Platform URLs

The searcher package uses specific URLs to direct searches to various platforms. Understanding these URLs can be helpful for troubleshooting or creating custom search functions.

Search Engines

The following search engines are supported with their corresponding base URLs:

Function Service Base URL
search_google() Google https://google.com/search?q=
search_bing() Bing https://bing.com/search?q=
search_duckduckgo() / search_ddg() DuckDuckGo https://duckduckgo.com/?q=
search_startpage() / search_sp() Startpage https://startpage.com/do/dsearch?query=
search_ecosia() Ecosia https://www.ecosia.org/search?q=
search_qwant() Qwant https://www.qwant.com/?q=
search_brave() Brave Search https://search.brave.com/search?q=
search_kagi() Kagi https://kagi.com/search?q=
search_rseek() Rseek https://rseek.org/?q=

Community Sites

Community and developer discussion platforms:

Function Service Base URL
search_stackoverflow() / search_so() StackOverflow https://stackoverflow.com/search?q=
search_posit_community() / search_posit() Posit Community https://forum.posit.co/search?q=
search_twitter() / search_x() Twitter/X https://twitter.com/search?q=
search_mastodon() Mastodon https://mastodon.social/search?q=
search_bluesky() BlueSky https://bsky.app/search?q=

Code Repositories

Code hosting and search platforms:

Function Service Base URL Additional Parameters
search_github() / search_gh() GitHub https://github.com/search?q= &type=Issues
search_grep() grep.app https://grep.app/search?q= N/A
search_bitbucket() / search_bb() BitBucket https://bitbucket.com/search?q= N/A

URL Construction

When you use a search function, the final URL is constructed by:

  1. Base URL: The platform’s search endpoint
  2. Encoded Query: Your search term, URL-encoded for safety
  3. R-specific Keywords: Added automatically when rlang = TRUE (default)
  4. Additional Parameters: Platform-specific options (like GitHub’s &type=Issues)

For example, when you run:

search_github("data visualization")

The constructed URL becomes:

https://github.com/search?q=data%20visualization%20language%3Ar%20type%3Aissue&type=Issues