knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

radous

R build
status Codecov test
coverage CRAN_Status_Badge CRAN_time_from_release CRAN_latest_release_date metacran
downloads metacran
downloads license R
badge

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.

Installation

You can radous from CRAN with:

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:

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.

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:

library(tidyverse)

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

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

Filter

Getting the users that are US citizens:

df %>% filter(nat == "US")

relocate

Relocating the last column nat to the beginning:

df %>% relocate(nat, before = gender)

group_by & summarise

Calculating median age by gender:

df %>% group_by(gender) %>% 
  summarise(median_age = median(dob_age))

count, arrange & desc

Getting the number of users per country of residence:

df %>% 
  count(location_country) %>% 
  arrange(desc(n))

filter & str_detect

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

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. By contributing to this project, you agree to abide by its terms.



feddelegrand7/radous documentation built on May 26, 2021, 6:12 p.m.