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
- Host: GitHub
- URL: https://github.com/feddelegrand7/radous
- Owner: feddelegrand7
- License: other
- Created: 2020-10-29T13:03:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-23T18:48:02.000Z (over 4 years ago)
- Last Synced: 2025-06-27T07:05:04.136Z (7 months ago)
- Topics: api, r, random-data, random-data-generation, rstats
- Language: R
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
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
[](https://github.com/feddelegrand7/radous/actions)
[](https://codecov.io/gh/feddelegrand7/radous?branch=master)
[](https://cran.r-project.org/package=radous)
[](https://cran.r-project.org/package=radous)
[](https://cran.r-project.org/package=radous)
[](https://cran.r-project.org/package=radous)
[](https://cran.r-project.org/package=radous)
[](https://choosealicense.com/licenses/mit/)
[](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.