Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tylerlittlefield/brewr

:beer: R Interface to Homebrews JSON API
https://github.com/tylerlittlefield/brewr

homebrew r rstats

Last synced: about 1 month ago
JSON representation

:beer: R Interface to Homebrews JSON API

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# brewr
[![Travis build status](https://travis-ci.org/tyluRp/brewr.svg?branch=master)](https://travis-ci.org/tyluRp/brewr)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/tyluRp/brewr?branch=master&svg=true)](https://ci.appveyor.com/project/tyluRp/brewr)
[![Codecov test coverage](https://codecov.io/gh/tyluRp/brewr/branch/master/graph/badge.svg)](https://codecov.io/gh/tyluRp/brewr?branch=master)

The goal of brewr is to access [Homebrews JSON API](https://formulae.brew.sh/docs/api/) in R.

## Installation

You can install brewr from github using [`devtools`](https://github.com/r-lib/devtools) with:

``` r
devtools::install_github("tylurp/brewr")
```

## Example

Use the `brewr()` function to access all API endpoints. The endpoints can be found [here](https://formulae.brew.sh/analytics/).

The first argument of `brewr()` is the endpoint. Note that the leading slash must be included as well.

```{r example, message=FALSE}
library(brewr)
library(dplyr)
library(jsonlite)

# Pull metrics on macOS versions
os_versions <- brewr("/analytics/os-version/30d")

# Default output is JSON
class(os_versions)

# Convert JSON to an R object with jsonlite
os_versions %>%
fromJSON() %>%
.$items

# Pull install metrics from the last 30 days
brewr("/analytics/install/30d") %>%
fromJSON() %>%
.$items %>%
head(10)

# Pull cask installs from the last 30d
brewr("/analytics/cask-install/30d") %>%
fromJSON() %>%
.$items %>%
head(10)
```

## Shiny demo

See the shiny demo app here: https://github.com/tyluRp/brewr-shiny