diff --git a/.Rbuildignore b/.Rbuildignore index 46f445b..3043632 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,5 @@ ^rmot\.Rproj$ ^\.Rproj\.user$ ^README\.Rmd$ +^doc$ +^Meta$ diff --git a/.gitignore b/.gitignore index c306966..0042aee 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ po/*~ # RStudio Connect folder rsconnect/ +inst/doc +/doc/ +/Meta/ diff --git a/DESCRIPTION b/DESCRIPTION index 3d20acc..67a5e01 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,3 +30,7 @@ LinkingTo: rstan (>= 2.18.1), StanHeaders (>= 2.18.0) SystemRequirements: GNU make +Suggests: + knitr, + rmarkdown +VignetteBuilder: knitr diff --git a/R/rmot_run.R b/R/rmot_run.R index 16ed4d2..c1575bf 100644 --- a/R/rmot_run.R +++ b/R/rmot_run.R @@ -7,8 +7,11 @@ #' @export #' #' @examples -#' mtcars -#' rmot_lm(mtcars$mpg, mtcars$disp) +#' rmot_model("linear") |> +#' rmot_assign_data(X = Loblolly$age, +#' Y = Loblolly$height, +#' N = nrow(Loblolly)) |> +#' rmot_run() rmot_run <- function(model_template, ...) { # Detect model diff --git a/README.Rmd b/README.Rmd index 62d9c2b..5d1e650 100644 --- a/README.Rmd +++ b/README.Rmd @@ -33,5 +33,13 @@ remotes::install_github("traitecoevo/rmot") ## Demo ```{r example} - +rmot_model("linear") |> + rmot_assign_data(X = Loblolly$age, + Y = Loblolly$height, + N = nrow(Loblolly)) |> + rmot_run() ``` + +## Found a bug? + +Please lodge a GitHub Issue with details of the bug diff --git a/README.md b/README.md index 2116902..be45a3b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # rmot @@ -18,3 +19,15 @@ remotes::install_github("traitecoevo/rmot") ``` ## Demo + +``` r +rmot_model("linear") |> + rmot_assign_data(X = Loblolly$age, + Y = Loblolly$height, + N = nrow(Loblolly)) |> + rmot_run() +``` + +## Found a bug? + +Please lodge a GitHub Issue with details of the bug diff --git a/man/rmot_run.Rd b/man/rmot_run.Rd index c399654..fb10e98 100644 --- a/man/rmot_run.Rd +++ b/man/rmot_run.Rd @@ -18,6 +18,9 @@ Stanfit model output Run a linear model in Stan } \examples{ -mtcars -rmot_lm(mtcars$mpg, mtcars$disp) +rmot_model("linear") |> + rmot_assign_data(X = Loblolly$age, + Y = Loblolly$height, + N = nrow(Loblolly)) |> + rmot_run() } diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/rmot.Rmd b/vignettes/rmot.Rmd new file mode 100644 index 0000000..6b708ff --- /dev/null +++ b/vignettes/rmot.Rmd @@ -0,0 +1,68 @@ +--- +title: "rmot" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{rmot} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) + +library(rmot) +``` + +## Goal of package + +## Installation + +'rmot' is under active development, you can install the development version of 'rmot' from [GitHub](https://github.com/) with: + +```{r, eval=FALSE} +# install.packages("remotes") +remotes::install_github("traitecoevo/rmot") + +library(rmot) +``` + +## {rmot} supported models + +### Linear model + +```{r example} +rmot_model("linear") |> + rmot_assign_data(X = Loblolly$age, + Y = Loblolly$height, + N = nrow(Loblolly)) |> + rmot_run() +``` + +### Constant Growth - Single Species + +```{r} +# Create data +true <- c(seq(from=1, by=2.5, length.out=7), + seq(from=2, by=2, length.out=7)) +y <- true + true*rnorm(n=14, 0, 0.02) + rnorm(n=14, 0, 0.2) + +# Configure model template +cgs_output <- rmot_model("constant_single") |> + rmot_assign_data(N_obs = length(y), + N_ind = 2, + S_obs = y, + census = rep(seq(from=1, to=7, by=1), times=2), #vector length N_obs + census_interval = rep(5, times=length(y)), #Vector length N_obs + id_factor = c(rep(1, times=7), rep(2, times=7)), #Vector length N_obs + S_0_obs = y[c(1, 8)] #vector length N_ind + ) |> + rmot_run() + +# Look at output +cgs_output +``` + +