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

non-numeric error in adjust_for_inflation() #43

Open
SaraPerrins opened this issue Jan 8, 2023 · 2 comments
Open

non-numeric error in adjust_for_inflation() #43

SaraPerrins opened this issue Jan 8, 2023 · 2 comments

Comments

@SaraPerrins
Copy link

SaraPerrins commented Jan 8, 2023

I've verified that my "price" and "from_date" parameters are numeric, but I get this error:

Error in price * multipliers : non-numeric argument to binary operator

Reproducible code:

require(priceR)

reproducible.df <- data.frame(mmhinco = as.numeric("10", "20", "30"), year = as.numeric("1980", "1999", "2012"))

reproducible.df$in_2018_dollars <- adjust_for_inflation(price = "mmhinco", from_date = "year" , "US", to_date = 2018)

is.numeric(reproducible.df$mmhinco)
[1] TRUE
is.numeric(reproducible.df$year)
[1] TRUE

@SaraPerrins SaraPerrins changed the title 2nd object in argument never found in adjust_for_inflation() non-numeric error in adjust_for_inflation() Jan 8, 2023
@stevecondylios
Copy link
Owner

stevecondylios commented Jan 8, 2023

Thanks for the excellent reproducible example, it makes it easy to diagnose.

Your code is almost there, try this:

require(priceR)

reproducible.df <- data.frame(mmhinco = as.numeric("10", "20", "30"), year = as.numeric("1980", "1999", "2012"))

reproducible.df$in_2018_dollars <- adjust_for_inflation(price = reproducible.df$mmhinco, from_date = reproducible.df$year , "US", to_date = 2018)

# View results
reproducible.df

#   mmhinco year in_2018_dollars
# 1      10 1980        30.47105

@SaraPerrins
Copy link
Author

Thanks for the quick solution!

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