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

https://github.com/feddelegrand7/radous

Query Random User Data From the Random User Generator API
https://github.com/feddelegrand7/radous

api r random-data random-data-generation rstats

Last synced: 6 months ago
JSON representation

Query Random User Data From the Random User Generator API

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# radous

[![R build
status](https://github.com/feddelegrand7/radous/workflows/R-CMD-check/badge.svg)](https://github.com/feddelegrand7/radous/actions)
[![Codecov test
coverage](https://codecov.io/gh/feddelegrand7/radous/branch/master/graph/badge.svg)](https://codecov.io/gh/feddelegrand7/radous?branch=master)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/radous)](https://cran.r-project.org/package=radous)
[![CRAN\_time\_from\_release](https://www.r-pkg.org/badges/ago/radous)](https://cran.r-project.org/package=radous)
[![CRAN\_latest\_release\_date](https://www.r-pkg.org/badges/last-release/radous)](https://cran.r-project.org/package=radous)
[![metacran
downloads](https://cranlogs.r-pkg.org/badges/radous)](https://cran.r-project.org/package=radous)
[![metacran
downloads](https://cranlogs.r-pkg.org/badges/grand-total/radous)](https://cran.r-project.org/package=radous)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://choosealicense.com/licenses/mit/)
[![R
badge](https://img.shields.io/badge/Build%20with-♥%20and%20R-red)](https://github.com/feddelegrand7/radous)

`radous` allows you to generate random user data from the [Random User Generator API](https://randomuser.me/) which can be useful in many situations :

- Teaching;
- Testing a function;
- Testing an application (Shiny, Dash or others)

__You can generate up to 5000 observations in one query.__

## Installation

You can `radous` from CRAN with:

```{r, eval=FALSE}
install.packages("radous")

```

## Usage

`radous` is extremely simple to use and has one function: `get_data()`.

Suppose we want to generate 10 random user data:

```{r}
library(radous)

get_data(n = 10)

```

If you want to generate always the same set of users, you can use the `seed` argument:

```{r}
get_data(n = 5, seed = "1990")

```

Let's run the above code again to check if we get the same info:

```{r}
get_data(n = 5, seed = "1990")

```

If you need some user images, it's easy to get:

```{r, message=FALSE, warning=FALSE}
library(dplyr)

random_image <- get_data(n = 1) %>% select(picture_large) %>% pull()

htmltools::img(src = random_image, height = "150px", width = "150px")

```

> Note that All randomly generated photos come from the authorized section of [UI Faces](https://uifaces.co/).

## Teaching with `radous` 👨‍🏫

The generated data has 34 variables (columns) with different types of information that you can play with. The data frame is particularly suited for teaching the tidyverse, here some examples:

#### Select

> Here we select columns that are related to users' location:

```{r message=FALSE, warning=FALSE}
library(tidyverse)

df <- get_data(n = 500, seed = "123")

df %>% select(contains("location"))

```

#### Filter

> Getting the users that are US citizens:

```{r message=FALSE, warning=FALSE}
df %>% filter(nat == "US")

```

#### relocate

> Relocating the last column `nat` to the beginning:

```{r}
df %>% relocate(nat, before = gender)

```

#### group_by & summarise

> Calculating median age by gender:

```{r}
df %>% group_by(gender) %>%
summarise(median_age = median(dob_age))
```

#### count, arrange & desc

> Getting the number of users per country of residence:
>

```{r}
df %>%
count(location_country) %>%
arrange(desc(n))
```

#### filter & str_detect

> Filtering out the users that have a cell number that begins with 081:

```{r}
df %>% select(1:3, cell) %>%
filter(str_detect(cell, "081"))


```

## Code of Conduct

Please note that the radous project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.