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

Serving size for nutrient info #2

Open
wordsmith189 opened this issue Sep 25, 2021 · 7 comments
Open

Serving size for nutrient info #2

wordsmith189 opened this issue Sep 25, 2021 · 7 comments

Comments

@wordsmith189
Copy link

wordsmith189 commented Sep 25, 2021

Good morning,

Thank you for this package. For the nutrient information retrieved with get_nutrients(), where can I grab the serving size information?

Many thanks!!

@wordsmith189 wordsmith189 added the bug Something isn't working label Sep 25, 2021
@Nelson-Gon
Copy link
Owner

Nelson-Gon commented Sep 26, 2021

Hi @wordsmith189,

Thank you for reporting this issue. It seems the package interfaces a very early version of the FDC API or perhaps there was an error in defining the API's url.
I will fix this sometime soon but in the meantime, you can either PR and fix this by changing https://github.com/Nelson-Gon/rfdc/blob/7bfaadbbe9538ad26441058dff8cc8aed1ee2f85/R/MethodDefinitions.R#L46-#L48 or try to search for "amount" using the get_food_details method (this may also not work).

The link to the API should look like https://github.com/Nelson-Gon/pyfdc/blob/f0635d03ee89231d58cb70aad752be858312a74e/pyfdc/pyfdc.py#L29 instead.

Thank you

@Nelson-Gon
Copy link
Owner

Hi @wordsmith189, please let me know if this fixes this issue or if further help is needed.

Thanks,
Nelson

Nelson-Gon added a commit that referenced this issue Sep 27, 2021
@wordsmith189
Copy link
Author

Hi, thanks - no, it doesn't fix it.

  • Using 'amount' as argument to get_food_details() returns NULL.
  • I would try to PR but don't fully get how the API outputs.
  • The get_nutrients() function returns data that is unparseable. The numbers don't make any sense as nutrition information. See example output that I'm attaching.

get_nutrients

Many thanks again!

@Nelson-Gon Nelson-Gon reopened this Sep 29, 2021
@Nelson-Gon
Copy link
Owner

Nelson-Gon commented Sep 29, 2021

Thanks for the feedback @wordsmith189,

Using the most recent commit, get_nutrients should return a data.frame that contains "amount" and what this means (see README). Could you fetch and see if this is what is needed?

I read the API [documentation](https://fdc.nal.usda.gov/api-spec/fdc_api.html#/FDC/get Foods Search) again but it's not clear what amount means. I assumed this is the RDA/serving.

If you need a more raw format, you can set target field to "foodNutrients" in get_food_details which will return a more detailed but raw output.

You can also PR to fix this by changing get_nutrients to work as per how you may have formatted the output from the call to get_food_details with "foodNutrients" as the target.

food_details <- get_food_details(object,target_field="foodNutrients")$foodNutrients

I still need to rewrite the get_nutrients code to specify formats (e.g. Abridged) though.

Happy to take a further look at this if it's still not what you need.

@wordsmith189
Copy link
Author

OK I see in the README that there are now columns serving and serving_descr, which look like they will help with the understanding. So thank you for that!

However, I tried to get the latest version by installing with remotes::install_github("Nelson-Gon/rfdc"), but I am not getting the two new columns (yet?). My output is still identical to what I showed in the screenshot in my earlier response.

@Nelson-Gon
Copy link
Owner

Thanks, I will check to see what could be the issue with getting the latest commit to work as expected.

Nelson-Gon added a commit to Nelson-Gon/pyfdc that referenced this issue Oct 3, 2021
@Nelson-Gon
Copy link
Owner

@wordsmith189, Hi it seems I am unable to reproduce the non-install issue. Could you create a new issue specific for the install?
Thanks,
Nelson

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

No branches or pull requests

2 participants