Created
June 17, 2021 19:08
-
-
Save tdsmith/c7217670b37c0b40a774c879c40fd4ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
library(dplyr) | |
n = 1000 | |
set.seed(42) | |
uuid_like = function() { | |
# Pretend to construct a UUID using the R PRNG. | |
s = paste0(sample(strsplit("0123456789abcdef", "")[[1]], 32, replace=TRUE), collapse="") | |
sprintf("%s-%s-%s-%s-%s", substr(s, 1, 8), substr(s, 9, 12), substr(s, 13, 16), substr(s, 17, 20), substr(s, 20, 32)) | |
} | |
reps = rpois(n, 2)+1 | |
uuids = sapply(1:n, function(.) uuid_like()) | |
branches = sample(c("branch_a", "branch_b", "branch_c"), n, replace=TRUE) | |
rows = sum(reps) | |
data = tibble( | |
client_id=rep(uuids, reps), | |
branches=rep(branches, reps), | |
active_hours=rlnorm(rows), | |
n_urls=as.integer(rlnorm(rows, 2, 2)), | |
n_searches=rpois(rows, 1000), | |
order=runif(rows) | |
) %>% | |
arrange(order) %>% | |
select(-order) | |
write_csv(data, "mock_data.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment