library(jsonlite)
# generate random id
generate_id <- function() paste0(sample(c(letters,
LETTERS, 0:9), 10,
replace=TRUE),
collapse="")
# real first names of people
first_names <- c("John", "Jane", "Michael",
"Emily", "William", "Ashley",
"David", "Jessica", "Andrew",
"Jennifer",
"Matthew", "Sarah", "Daniel",
"Amanda", "Christopher", "Elizabeth",
"Nicholas", "Megan", "Robert",
"Lauren", "Joseph", "Ava", "Jacob",
"Sophia", "Jonathan", "Natalie", "Ryan",
"Madison", "Adam", "Chloe")
# real last names of people
last_names <- c("Smith", "Johnson", "Williams", "Jones",
"Brown", "Davis", "Miller", "Wilson",
"Moore", "Taylor",
"Anderson", "Thomas", "Jackson", "White",
"Harris", "Martin", "Thompson", "Garcia",
"Martinez", "Robinson",
"Clark", "Rodriguez", "Lewis", "Lee", "Walker",
"Hall", "Allen", "King", "Wright", "Scott")
# education qualifications
qualifications <- c("Primary Education", "Secondary Education",
"High School", "Undergraduate", "Postgraduate")
# create a data frame
df <- data.frame(ID = sapply(1:1000000,
function(i) generate_id()),
First_Name = sample(first_names,
1000000, replace = TRUE),
Last_Name = sample(last_names,
1000000, replace = TRUE),
Age = sample(18:30, 1000000,
replace = TRUE),
Highest_qualification =
sample(qualifications, 1000000,
replace = TRUE),
stringsAsFactors = FALSE)
# write the data frame to a JSON file
write_json(df, "people.json")