This script shows the code for generating the necessary data frames used in the workshop.
library(tidyverse)
Vampires =
tibble(
idVampire = 1:100,
gender = rnorm(n = 100, mean = 0, sd = 1),
ageOfVampire = abs(round(rnorm(n = 100, mean = 80, sd = 30))),
deadOrAlive = rnorm(n = 100, mean = 0, sd = 1),
hasFangs = rnorm(n = 100, mean = 0, sd = 1),
bornIn = rnorm(n = 100, mean = 5, sd = 2),
vampType = rnorm(n = 100, mean = 3, sd = 1),
wellbeing = runif(n = 100, min = 0, max = 100),
maritalStatus = rnorm(n = 100, mean = 3, sd = 1),
employment = rnorm(n = 100, mean = 0, sd = 1),
income = rnorm(n = 100, mean = 140000, sd = 30000),
visitedCities = round(abs(exp(rnorm(n = 100, mean = 3, sd = 1)))),
numberOfChildren = round(abs(rnorm(n = 100, mean = 3, sd = 2))),
numberChangedToVamp = round(abs(exp(rnorm(n = 100, mean = 2, sd = .5))))
) %>%
mutate(idVampire = as.factor(idVampire),
gender = ifelse(gender < 0, "Male", "Female"),
deadOrAlive = ifelse(deadOrAlive < 0, "Dead", "Alive"),
hasFangs = ifelse(hasFangs < 0, "Yes", "No"),
vampType = ifelse(vampType <= 2, "sanguinarian",
ifelse(vampType > 2 & vampType < 3, "psychic", "hybrid")),
maritalStatus = ifelse(maritalStatus <= 2, "Married",
ifelse(maritalStatus > 2 & maritalStatus < 3,
"Single", "Divorced")),
employment = ifelse(employment < 0, "Employed", "Not Employed"),
bornIn = ifelse(bornIn < 1, "Asia",
ifelse(bornIn >= 1 & bornIn < 2, "Africa",
ifelse(bornIn >= 2 & bornIn < 3, "Europa",
ifelse(bornIn >= 3 & bornIn < 4, "North America",
ifelse(bornIn >= 4 & bornIn < 5, "South America",
ifelse(bornIn >= 5 & bornIn < 6, "Australia", "Antarctica")))))))
write_csv(Vampires, file = "./Data/Vampires.csv") # write the file
Export the mtcars
and swiss
data frames as a .csv files to upload to the workshop website.