Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
144 lines (97 sloc) 5.25 KB
title: Search and discover CRAN packages with pkgsearch!
date: '2019-11-26'
slug: pkgsearch
- pkgsearch
We have just released version 3.0.1 of the `pkgsearch` package [on CRAN](! :tada: `pkgsearch` munges CRAN metadata and lets you
access it through several lenses: **search packages by keyword, popularity, recent activity, package name and more.**
Get `pkgsearch`'s latest version from
a [safe]( CRAN mirror near
This release, compared to `pkgsearch` 2.0.0, brings
:mag_right: Better package search functionality
* New RStudio addin to search for packages in a GUI: `pkg_search_addin()`.
* New function `advanced_search()` for more search flexibility.
:mag_right: New functionality
* `cran_package()`, `cran_packages()` and `cran_package_history()` functions to query metadata about certain packages.
* `cran_events()` function to list recent CRAN events, new, updated or archived packages.
* `cran_top_downloaded()` function to query packages with the most downloads.
* `cran_trending()` function to return the trending CRAN packages.
That's... a lot! Let's have some fun with the package.
## Explore packages in a GUI
You can use `pkgsearch` with an interface. See more in the video below. You can also launch the interface in a browser without RStudio, [refer to the addin docs](
```{r addin, echo = FALSE}
blogdown::shortcode("vimeo", "375618736")
## Other use cases
The `pkgsearch` package is the answer to many questions you might have about CRAN packages, thanks to its exposing it through different lenses.
```{r load}
### Packages to do mocking
Remember our [blog post about mocking when unit testing](/2019/10/29/mocking/)? How could we search CRAN packages related to mocking?
```{r mock}
### Dependencies of a package over time?
```{r tweet, echo = FALSE}
blogdown::shortcode("tweet", "1186667832718876673")
YES, we know! :grin: :raised_hand: So say we want to query the dependencies of `tsibble`, we can use `cran_package_history()` for that.
```{r tsibble1}
cran_package_history("tsibble")[, c("Package", "Version", "dependencies")] %>%
Or of one particular version of `tsibble`, then we can run `cran_packages()` (or `cran_package()` with its `version` argument, that returns a list).
```{r tsibble2}
info <- cran_package("tsibble", version = "0.2.0")
info[c("Imports", "Suggests", "Depends")]
### When was the CRAN incoming queue closed?
From time to time [CRAN incoming queue is closed](, for instance earlier this year from August 9 to August 18. Can we see that in the data?
```{r echo=FALSE, warning=FALSE, results='hide'}
```{r cranvacay, cache=TRUE}
cran_events <- cran_events(limit = 5000)
events_df <- tibble::tibble(
date = anytime::anytime(purrr::map_chr(cran_events, "date")),
type = purrr::map_chr(cran_events, "event")
ggplot(events_df) +
geom_segment(aes(x = date, xend = date,
col = type),
y = 0, yend = 1) +
viridis::scale_colour_viridis(discrete = TRUE) +
theme_minimal() +
hrbrthemes::theme_ipsum(base_size = 16,
axis_title_size = 16) +
xlab("Time") +
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
legend.position = "bottom") +
ggtitle("Latest 5,000 CRAN events",
subtitle = "Data obtained via the R-hub pkgsearch R package")
So yes, we do see the CRAN (well-deserved!) break in the data!
## Related work
Without surprise `pkgsearch` is our favorite CRAN metadata munger since it is _ours_, but we know of other great tools!
* The [`packagefinder` package]( by Joachim Zuckarelli aims at providing a Comfortable Search for R Packages on CRAN Directly from the R Console.
* [`CRANberries`]( by Dirk Eddelbuettel "aggregates information about new, updated and removed packages from the CRAN network for R available as this html version and a corresponding RSS feed." and a Twitter feed. Handy!
## Conclusion
In this post we gave an overview of `pkgsearch` functionalities. It could become your go-to package for searching and exploring CRAN packages thanks to its exposing CRAN metadata in different ways: packages related to a keyword, trending packages, information about a package, etc. And you can use it either from the R console or a GUI!
The best place to get to know `pkgsearch` is [its brand-new documentation website built with `pkgdown`](, and the best place to provide feedback or contribute is [its GitHub repo]( We look forward to hearing from your use cases, and hope your enthusiasm for the package can push it to the `cran_trending()` VIP list! :wink:
```{r last-ex}
pkg_search("search CRAN")
You can’t perform that action at this time.