knitr::opts_chunk$set( collapse = TRUE, comment = "", fig.path = "man/figures/README-", out.width = "100%" )
radous
allows you to generate random user data from the Random User Generator API which can be useful in many situations :
You can generate up to 5000 observations in one query.
You can radous
from CRAN with:
install.packages("radous")
radous
is extremely simple to use and has one function: get_data()
.
Suppose we want to generate 10 random user data:
library(radous) get_data(n = 10)
If you want to generate always the same set of users, you can use the seed
argument:
get_data(n = 5, seed = "1990")
Let's run the above code again to check if we get the same info:
get_data(n = 5, seed = "1990")
If you need some user images, it's easy to get:
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.
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:
Here we select columns that are related to users' location:
library(tidyverse) df <- get_data(n = 500, seed = "123") df %>% select(contains("location"))
Getting the users that are US citizens:
df %>% filter(nat == "US")
Relocating the last column
nat
to the beginning:
df %>% relocate(nat, before = gender)
Calculating median age by gender:
df %>% group_by(gender) %>% summarise(median_age = median(dob_age))
Getting the number of users per country of residence:
df %>% count(location_country) %>% arrange(desc(n))
Filtering out the users that have a cell number that begins with 081:
df %>% select(1:3, cell) %>% filter(str_detect(cell, "081"))
Please note that the radous project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.