#replace blank and 0 values with NAbillionaires_final <-read.csv("data/billionaires.csv", na.strings =c("", "0"))#rename private equitybillionaires_final <- billionaires_final |>mutate(wealth.how.industry =ifelse(wealth.how.industry =="Private equity/leveraged buyout", "Private equity", wealth.how.industry) )#Filtered to include only 2014 and 1996, also drops values in the #wealth.how.industry column that is missing billionaires_final <- billionaires_final |>filter(year %in%c(2014, 1996), !is.na(wealth.how.industry)) |>#Mutated so that wealth.how.industry says "yes" if value in the "Technology-Computer" industry# Says "no" if value not in the industrymutate(wealth.how.industry =ifelse(wealth.how.industry =="Technology-Computer", "yes", "no"),year =as.factor(year),year =fct_relevel(.f = year, "2014" , "1996"),wealth.how.industry =as.factor(wealth.how.industry))#Makes a column to add if wealth was inherited or not inherited billionaires_final <- billionaires_final |>mutate(inherited =if_else(str_detect(wealth.how.inherited, "not inherited"), "not inherited", "inherited")) |>filter(year %in%c(2014, 1996)) |>mutate(year =as.factor(year),year =fct_relevel(.f = year, "2014" , "1996"))write.csv(billionaires_final, "data/billionaires_final")
We replaced blank and 0 values with NA
We renamed the “Private equity/leveraged buyout” value for the wealth.how.industry variable to “Private equity”
We filtered out rows that had an NA value for the wealth.how.industry variable
We made a new variable inherited that describes if the billionaire inherited their wealth