Skip to contents
library(wontrun)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(purrr)

We need to start with a list of packages. Using get_packages_from_view(), we get a data frame with packages from a CRAN Task View. But you can provide any data frame with a column called name where each element is a package name. The lines below show you how to get a data frame, called econ_source that contains the packages from the Econometrics view as of “2015-01-01”.

ctv_econ <- get_packages_from_view("Econometrics", date = "2015-01-01")
econ_source <- get_sources_for_selected_packages(ctv_econ)

To make things easier, you can load a sample of packages with the following line:

data("sources_ctv_econ")

sources_ctv_econ
#> # A tibble: 10 × 6
#>    view         name            version          url   last_modified       size 
#>    <chr>        <I<chr>>        <chr>            <chr> <dttm>              <chr>
#>  1 Econometrics mlogit          mlogit_0.1-8     http… 2010-07-24 22:21:00 632K 
#>  2 Econometrics gmm             gmm_1.3-3        http… 2010-09-26 20:14:00 1.0M 
#>  3 Econometrics mgcv            mgcv_1.7-2       http… 2010-11-13 16:19:00 443K 
#>  4 Econometrics sampleSelection sampleSelection… http… 2010-08-12 13:22:00 2.7M 
#>  5 Econometrics strucchange     strucchange_1.4… http… 2010-12-14 10:52:00 756K 
#>  6 Econometrics timeSeries      timeSeries_2130… http… 2010-10-27 16:44:00 784K 
#>  7 Econometrics dynlm           dynlm_0.3-0      http… 2010-10-12 12:12:00 20K  
#>  8 Econometrics boot            boot_1.2-43      http… 2010-09-25 12:58:00 208K 
#>  9 Econometrics sandwich        sandwich_2.2-6   http… 2010-03-03 01:20:00 861K 
#> 10 Econometrics Zelig           Zelig_3.4-8      http… 2010-01-21 08:13:00 11M

It is now possible to download the documentation from the packages to a temporary directory with:

sources_ctv_econ_with_path <- get_examples(sources_ctv_econ)
#> Downloading package mlogit_0.1-8
#> Downloading package gmm_1.3-3
#> Downloading package mgcv_1.7-2
#> Downloading package sampleSelection_0.6-10
#> Downloading package strucchange_1.4-3
#> Downloading package timeSeries_2130.90
#> Downloading package dynlm_0.3-0
#> Downloading package boot_1.2-43
#> Downloading package sandwich_2.2-6
#> Downloading package Zelig_3.4-8
hu <- run_examples(filter(sources_ctv_econ_with_path, name == "gmm"))
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/bread.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/charStable.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/coef.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/confint.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/estfun.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/fitted.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/formula.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/gel.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/getDat.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/getLamb.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/gmm.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/plot.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/print.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/residuals.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/smoothG.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/specTest.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/summary.RNULL
#> Loading  gmm 
#>  and running  /tmp/RtmpxpBDV8wontrun_download/gmm/gmm_1.3-3/scripts/vcov.RNULL
#> Warning: UNRELIABLE VALUE: Future ('<none>') unexpectedly generated random
#> numbers without specifying argument 'seed'. There is a risk that those random
#> numbers are not statistically sound and the overall results might be invalid.
#> To fix this, specify 'seed=TRUE'. This ensures that proper, parallel-safe random
#> numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use
#> 'seed=NULL', or set option 'future.rng.onMisuse' to "ignore".