silentspringinstitute / rnhanes Goto Github PK
View Code? Open in Web Editor NEWR package for accessing and analyzing CDC NHANES data
License: Apache License 2.0
R package for accessing and analyzing CDC NHANES data
License: Apache License 2.0
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
When I run either:
files <- nhanes_data_files()
variables <- nhanes_variables()
I get :
trying URL 'https://wwwn.cdc.gov/nchs/nhanes/search/variablelist.aspx?Component=Demographics'
Content type 'text/html; charset=utf-8' length 1382905 bytes (1.3 MB)
downloaded 1.3 MB
Error in dat[[2]] : subscript out of bounds
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.
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.
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?)'
Line 32 in 62d9973
Line 138 in 62d9973
Hi,
running 'files <- nhanes_data_files()' produced the error
**Downloading NHANES data file list to C:\Users\ark007\AppData\Local\Temp\RtmpSO4zcU\file315451c614d2
trying URL 'https://wwwn.cdc.gov/Nchs/Nhanes/Search/DataPage.aspx?Component=demographics'
Content type 'text/html; charset=utf-8' length 392824 bytes (383 KB)
downloaded 383 KB
Error in dat[[2]] : subscript out of bounds**
I am not sure how to fix it.
Best,
Arkaprava
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")
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:
Line 191 in 1cb3cbf
A simple fix perhaps would be to recognize the "P_" cycle and ignore the name checks?
I'm using these data in a textbook and was hoping to access directly via the RNHANES package on CRAN...any chance it will be updated in the next few months?
Thanks!
Jenine
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!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.