-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
216 lines (126 loc) · 4.21 KB
/
Copy pathREADME.Rmd
File metadata and controls
216 lines (126 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# radous
<!-- badges: start -->
[](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)
<!-- badges: end -->
`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
<details>
<summary>
> Here we select columns that are related to users' location:
</summary>
```{r message=FALSE, warning=FALSE}
library(tidyverse)
df <- get_data(n = 500, seed = "123")
df %>% select(contains("location"))
```
</details>
#### Filter
<details>
<summary>
> Getting the users that are US citizens:
</summary>
```{r message=FALSE, warning=FALSE}
df %>% filter(nat == "US")
```
</details>
#### relocate
<details>
<summary>
> Relocating the last column `nat` to the beginning:
</summary>
```{r}
df %>% relocate(nat, before = gender)
```
</details>
#### group_by & summarise
<details>
<summary>
> Calculating median age by gender:
</summary>
```{r}
df %>% group_by(gender) %>%
summarise(median_age = median(dob_age))
```
</details>
#### count, arrange & desc
<details>
<summary>
> Getting the number of users per country of residence:
>
</summary>
```{r}
df %>%
count(location_country) %>%
arrange(desc(n))
```
</details>
#### filter & str_detect
<details>
<summary>
> Filtering out the users that have a cell number that begins with 081:
</summary>
```{r}
df %>% select(1:3, cell) %>%
filter(str_detect(cell, "081"))
```
</details>
## 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.