GithubHelp home page GithubHelp logo

silentspringinstitute / rnhanes Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 9.0 245 KB

R package for accessing and analyzing CDC NHANES data

License: Apache License 2.0

R 100.00%
cran nhanes publichealth rstats

rnhanes's People

Contributors

herbps10 avatar jrm5100 avatar kristin-ssi avatar workingonstuff avatar xiaosongz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rnhanes's Issues

Unable to extract nhanes data from year 2015-2016

I am Unable to extract nhanes data from year 2015-2016 and is failing with the error below. Request to please look into the issue. Thanks a lot.

sample <- nhanes_load_data("DEMO","2015-2016", cache = "./nhanes_data", demographics = TRUE, recode = TRUE)
is throwing error : Error in validate_year(year) : Invalid year: 2015-2016

Clarify documentation of nhanes_vcov

The documentation file for nhanes_vcov is too vague about what the function does. Specifically, it returns the variance-covariance matrix of the svymean statistic as computed by the survey package. The doc file implies that it is computing the covariance matrix between nhanes variables, which is unnecessarily confusing.

Recoding throws an error for variables without a table in the codebook

The load_nhanes_description function assumes that every variable (other than SEQN) will have an html table:

if(var_name != "SEQN") {
      values <- section %>%
        html_node("table") %>%
        html_table()

This causes an error when an html table doesn't exist. This happens for variables that seem to be used as directions for taking the survey and aren't reported in the data files anyway.

Examples are BPQ045 in 1999-2000 and ACQ005 in 2001-2002.

Issue downloading files in RStudio Server

I'm having an issue running the nhanes_data_files() function. The exact error is shown below, it seems to be when using download.file and more specifically the method = 'auto' portion. If I take out that part and let download.file select the method there is no error and it downloads fine. I'm not well versed in download.file so I don't know if that needs to stay method = 'auto' or not, but I figured I would bring it to your attention. If this can't be changed I can always fork the repo. Thanks.

> files <- nhanes_data_files()
Downloading NHANES data file list to /tmp/RtmpAPJ4To/file709c1de6be7c
trying URL 'https://wwwn.cdc.gov/Nchs/Nhanes/Search/DataPage.aspx?Component=demographics'
Error in download.file(url, destination, method = "auto", mode = "wb") : 
  cannot open URL 'https://wwwn.cdc.gov/Nchs/Nhanes/Search/DataPage.aspx?Component=demographics'
In addition: Warning message:
In download.file(url, destination, method = "auto", mode = "wb") :
  URL 'https://wwwn.cdc.gov/Nchs/Nhanes/Search/DataPage.aspx?Component=demographics': status was 'Problem with the SSL CA cert (path? access rights?)'

download.file(url, destination, method='auto', mode='wb')

download.file(url, destination, method='auto', mode='wb')

nhanes_survey will not run svyvar

When I run the following code I receive the error

"Error in as.vector(survey_fun(formula, ..., design = des)) :
object 'svyvar' not found"

I have checked the survey package to ensure that svyvar is, in fact, the correct argument. ANy help fixing this issue would be greatly appreciated.

library(tidyverse)
library(devtools)
install_github("silentspringinstitute/RNHANES", force = TRUE)
require(RNHANES)
require(survey)

phth_data <- nhanes_load_data("PHTHTE", "2013-2014", demographics = TRUE)
phth_data[,48] <- ifelse(phth_data[,48] >= 2, 1, 0)

nhanes_survey(svyvar, phth_data, column = "URXCNP",
comment_column = "URDCNPLC",
weights_column = "WTSB2YR",
filter = INDFMPIR==0 & RIDRETH3==1,
analyze = "values")

2017-2020 cycle load error due to improper suffix handling

There exists an issue (example below) in which combined files from the 2017-2020 NHANES cycle cannot be loaded with the usual RNHANES functions:

paq <- nhanes_load_data("P_SLQ", "2017-2020", demographics = TRUE, cache=F). # error, tries to load "P_SLQ_.XPT"

This error appears to stem from the changed naming convention format of the combined 2017-2020 cycle. As far as I can tell, the error occurs because of the way in which RNHANES tries to recognize a problem in the filename and appends a suffix:

dest_file_name <- paste0(year_suffix, "_", file_name)

A simple fix perhaps would be to recognize the "P_" cycle and ignore the name checks?

Cannot download BPX data after 2011-2012

Hello, I have used the following code structure successfully before to download and use other data files from the RNHANES package, but I cannot seem to get 2015-2016 files to load in. Has something changed:

nhanes2016 <- nhanes_load_data("BPX_I", "2015-2016", demographics = TRUE)

I get an "Invalid year: 2015-2016" Error in validate_year(year).

I am able to open the data directly from the URL: https://wwwn.cdc.gov/Nchs/Nhanes/2015-2016/BPX_I.XPT

Thanks!

Correlations between variables

Add functionality for computing different types of correlation estimates between NHANES variables.

Ideally there should be a function nhanes_cor which takes columns and returns a correlation matrix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.