Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example suggestion #64

Open
mjwebster opened this issue Dec 11, 2019 · 1 comment
Open

example suggestion #64

mjwebster opened this issue Dec 11, 2019 · 1 comment

Comments

@mjwebster
Copy link

mjwebster commented Dec 11, 2019

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(>=, <=))

@chriseshleman
Copy link

Very cool :)

This worked until the very last line ("people <- fuzzy... "):

Error in parse(text = x, srcfile = src): :4:122: unexpected '>='

Do you have suggestions?

Best,
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants