Provides a search interface to look up terms on 'Google', 'Bing', 'DuckDuckGo', 'Startpage', 'StackOverflow', 'RStudio Community', 'GitHub', and 'BitBucket'. Upon searching, a browser window will open with the aforementioned search results.
The goal of searcher
is to provide a search interface directly inside
of R. For example, within R, there is now the ability to look up
rcpp example numeric vector
or ggplot2 fix axis labels
without
having to open a browser, go to a search site, and type the query. By
default, the search functions automatically search the last error on
call.
The searcher
package is available on both CRAN and GitHub. The CRAN
version is considered stable while the GitHub version is in a state of
development and may break. You can install the stable version of the
searcher
package with:
install.packages("searcher")
For the development version, you can opt for:
install.packages("devtools")devtools::install_github("coatless/searcher")
library(searcher)
The search_*()
functions can be used to search a query directly from
R on major search engines, code repositories, and help websites. The
following search platforms are supported: Google, Bing, ixquick,
DuckDuckGo, StackOverflow, GitHub, and BitBucket. By default, an
appropriate suffix for each platform that ensures relevant results to
R is appended to all queries. This behavior can be disabled by using
rlang = FALSE
.
# Searching R project on major search enginessearch_google("R project")search_bing("R project")search_ixquick("R project")search_duckduckgo("R project") # or search_ddg(...)# Searching for linear regression questions for R and in generalsearch_stackoverflow("linear regression")search_stackoverflow("linear regression", rlang = FALSE) # or search_so(...)# Searching GitHub Issues for maps in R and other languagessearch_github("maps")search_github("maps", rlang = FALSE) # or search_gh(...)# Searching BitBucket for assertions in R and other languagessearch_bitbucket("assertions")search_bitbucket("assertions", rlang = FALSE) # or search_bb(...)
searcher
offers preliminary support for automatically or manually
searching errors that are generated in R. For more robust error search
support and to also search warning messages, please use the
errorist
package.
Searching the last error automatically is possible by registering a
function as R’s error handler via either searcher(site="")
or one of
the search_*()
functions. Thus, when an error occurs, this function
will automatically be called. This triggers a new browser window to open
with the error term listed in verbatim.
# Using the generic search error handleroptions(error = searcher("google"))# Directly specify the search functionoptions(error = search_github)options(error = search_google)
Alternatively, these functions can also be used manually so that the default error dispatch is preserved. In the manual case, you will have to explicitly call the search function. After that, a browser window will open with the last error message as the search query on the desired search portal.
search_google()search_bing()search_duckduckgo() # or search_ddg()search_stackoverflow() # or search_so()search_github() # or search_gh()search_bitbucket() # or search_bb()
The idea for searcher
began as a project to automatically search
errors and warnings that occurred while working with R after a
conversation among Dirk Eddelbuettel,
Barry Rowlingson, and myself. However,
there was no search interface that allowed querying directly from R
outside of the built-in
utils::RSiteSearch()
,
which only queries http://search.r-project.org/, and the
sos
package, which queries
an off-site user premade database. Both of these options were focused
solely on querying R documentation made available by packages. Given
the nature of errors generally being undocumented, neither of these
approaches could be used. Thus, searcher
was unintentionally born to
provide a means for errorist
,
which contains a robust way to automatically searching errors and
warnings.
GPL (>= 2)
search_ixquick()
: Searches with ixquick. (#8, #6)r programming
to major search engines by default (#11, #10)ixquick
as a valid engine to search_site()
. (#8, #6)DESCRIPTION
.search_site()
: Looks up search portal and then searches with it.search_google()
: Searches with Googlesearch_bing()
: Searches with Bingsearch_duckduckgo()
or search_ddg()
: Searches with DuckDuckGosearch_github()
or search_gh()
: Searches issues on GitHubsearch_bitbucket()
or search_bb()
: Searches issues on BitBucketsearch_stackoverflow()
or search_so()
: Searches questions on StackOverflowsearcher()
to create function objects that can be
used as error handlers in option(error = )
and task call-backs.browse_url()
that checks to see if it is in interactive mode before
trying to open a web browser 0.5 seconds after call.