Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ SystemRequirements: pandoc
Imports: desc, stats, utils, Rcpp (>= 0.12.16), RcppParallel (>= 5.0.1)
Suggests:
rstan (>= 2.17.2),
BH (>= 1.66.0),
RcppEigen (>= 0.3.3.3.0),
usethis (>= 1.5.1),
testthat (>= 2.0.0),
knitr,
pkgbuild,
pkgload,
roxygen2 (>= 6.0.1),
roxygen2 (>= 7.0.0),
rmarkdown,
rstudioapi
RoxygenNote: 7.3.3
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
Config/roxygen2/version: 8.0.0
2 changes: 2 additions & 0 deletions man/rstantools-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions vignettes/minimal-rstan-package.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ model {
}
"
writeLines(stan_prog, con = file.path(PATH, "inst", "stan", "lm.stan"))
rstan_config(PATH)
```

The `inst/stan` subdirectory can contain additional Stan programs if
Expand All @@ -179,7 +178,7 @@ the package functions. The following comment block placed in `lm_stan.R`
ensures that the function has a help file and that it is added to the package
`NAMESPACE`:

```{r}
```{r, eval=FALSE}
# Save this file as `R/lm_stan.R`

#' Bayesian linear regression with Stan
Expand Down Expand Up @@ -235,17 +234,18 @@ information about the package.

With __roxygen__ documentation enabled, we need to generate the documentation
for `lm_stan` and update the `NAMESPACE` so the function is exported, i.e.,
available to users when the package is installed. This can be done with the
function `roxygen2::roxygenize()`, which needs to be called twice initially.
available to users when the package is installed. Load the R source files
directly when running `roxygen2::roxygenize()`, then call `rstan_config()` to
generate the Stan C++ code:

```{r, eval = FALSE}
try(roxygen2::roxygenize(load_code = rstantools_load_code), silent = TRUE)
roxygen2::roxygenize()
roxygen2::roxygenize(load_code = roxygen2::load_source)
rstantools::rstan_config()
```

```{r, echo=FALSE, results="hide"}
try(roxygen2::roxygenize(PATH, load_code = rstantools_load_code), silent = TRUE)
roxygen2::roxygenize(PATH)
roxygen2::roxygenize(PATH, load_code = roxygen2::load_source)
rstan_config(PATH)
```

## Install and use
Expand All @@ -268,11 +268,8 @@ documentation, you can set `quick=TRUE` to speed up the process, or use

After installation, the package can be loaded and used like any other R package:

```{r, eval=FALSE}
library("rstanlm")
```

```{r}
library(rstanlm)
fit <- lm_stan(y = rnorm(10), x = rnorm(10),
# arguments passed to sampling
iter = 2000, refresh = 500)
Expand Down
Loading