You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for this package! I used it for assigning people to generations (Boomers, Millenials, etc) depending on the year they were born (also possible to base it on age using that as a rough approximation of year they were born, but that's more complicated code). Here's some simplified code of how I used fuzzyjoin.
#there's a dummy year in here for Generation ? endyr <- c(2025, 2016, 1996, 1983, 1976, 1962, 1943)
generations <- data.frame(name, startyr, endyr)
#create a data table of people with the year they were born name <- c("person1", "person2", "person3", "person4", "person5", "person6", "person7", "person8", "person9")
#Update the people table to indicate what generation they belong to
#depending on whether their birth year falls on or after start yr and on or before end year of the generation
people <- fuzzy_left_join( people, generations, by = c( "yr_birth" = "startyr", "yr_birth" = "endyr" ), match_fun = list(>=, <=))
The text was updated successfully, but these errors were encountered:
Thank you for this package! I used it for assigning people to generations (Boomers, Millenials, etc) depending on the year they were born (also possible to base it on age using that as a rough approximation of year they were born, but that's more complicated code). Here's some simplified code of how I used fuzzyjoin.
library(fuzzyjoin)
#create generations table
name <- c("Generation ?", "Generation Z", "Millenials", "Xennials", "Generation X", "Baby Boomers","Silent")
startyr <- c(2017, 1997, 1984, 1977, 1963, 1944, 1900)
#there's a dummy year in here for Generation ?
endyr <- c(2025, 2016, 1996, 1983, 1976, 1962, 1943)
generations <- data.frame(name, startyr, endyr)
#create a data table of people with the year they were born
name <- c("person1", "person2", "person3", "person4", "person5", "person6", "person7", "person8", "person9")
yr_birth <- c(1971, 2018, 1999, 1917, 1965, 1949, 1979, 1983, 1989)
people <- data.frame(name, yr_birth)
#Update the people table to indicate what generation they belong to
#depending on whether their birth year falls on or after start yr and on or before end year of the generation
people <- fuzzy_left_join( people, generations, by = c( "yr_birth" = "startyr", "yr_birth" = "endyr" ), match_fun = list(
>=,
<=))
The text was updated successfully, but these errors were encountered: