ajdamico / lodown

locally download and prepare publicly-available microdata
GNU General Public License v3.0
97 stars 47 forks source link

NSDUH Catalog #183

Closed tlcaputi closed 10 months ago

tlcaputi commented 3 years ago

lodown is an excellent project that I've enjoyed for several years now. However, it seems the NSDUH functions may need an update:

Reproducible example (from http://asdfree.com/national-study-on-drug-use-and-health-nsduh.html):

library(lodown)
devtools::install_github( "ajdamico/lodown" , dependencies = TRUE )

# examine all available NSDUH microdata files
nsduh_cat <-
  get_catalog( "nsduh" ,
               output_dir = file.path( path.expand( "~" ) , "NSDUH" ) )

# 2016 only
nsduh_cat <- subset( nsduh_cat , year == 2016 )
# download the microdata to your local computer
nsduh_cat <- lodown( "nsduh" , nsduh_cat )

Output (catalog won't build):

> library(lodown)
> # examine all available NSDUH microdata files
> nsduh_cat <-
+   get_catalog( "nsduh" ,
+                output_dir = file.path( path.expand( "~" ) , "NSDUH" ) )
building catalog for nsduh

Error in data.frame(year = link_year, full_url = link_url, output_filename = paste0(output_dir,  : 
  arguments imply differing number of rows: 0, 1
> 
> # 2016 only
> nsduh_cat <- subset( nsduh_cat , year == 2016 )
Error in subset(nsduh_cat, year == 2016) : object 'nsduh_cat' not found
> # download the microdata to your local computer
> nsduh_cat <- lodown( "nsduh" , nsduh_cat )
Error in lodown("nsduh", nsduh_cat) : object 'nsduh_cat' not found

Expected Behavior: Download 2016 NSDUH into ~/NSDUH

System Info:

> R.Version()
$platform
[1] "x86_64-w64-mingw32"

$arch
[1] "x86_64"

$os
[1] "mingw32"

$system
[1] "x86_64, mingw32"

$status
[1] ""

$major
[1] "4"

$minor
[1] "0.0"

$year
[1] "2020"

$month
[1] "04"

$day
[1] "24"

$`svn rev`
[1] "78286"

$language
[1] "R"

$version.string
[1] "R version 4.0.0 (2020-04-24)"

$nickname
[1] "Arbor Day"

Comments: Let me know if you have trouble reproducing my error. Thank you for this excellent project!

ajdamico commented 3 years ago

thanks! it would be great if you could propose a fix with a pull request

ajdamico commented 10 months ago

hi! apologies for the long delay. i've made a couple of big updates to asdfree.com that hopefully make the website a bit better, but i've decided to stop maintaining the lodown package so probably won't fix the bug you've reported. the new asdfree does have nsduh data, but only for the most current year. thanks