--- title: "Small Rmarkdown example with opticut and knitr" date: "`r format(Sys.time(), '%B %d, %Y')`" output: pdf_document --- # Introduction This is a small example demonstrating how to include opticut results into Rmarkdown (Rmd) documents. ```{r setup} library(opticut) library(knitr) ocoptions(cut=-Inf) ``` # Analysis ## Data set We have the following data set: ```{r data} ## community data y <- cbind( Sp1=c(4,6,3,5, 5,6,3,4, 4,1,3,2), Sp2=c(0,0,0,0, 1,0,0,1, 4,2,3,4), Sp3=c(0,0,3,0, 2,3,0,5, 5,6,3,4)) ## stratification g <- c(1,1,1,1, 2,2,2,2, 3,3,3,3) ``` ## Finding optimal partitions Here is the real deal: ```{r opticut} oc <- opticut(formula = y ~ 1, strata = g, dist = "poisson") summary(oc) oc$species[[1]] ``` The opticut object and its summary are lists, thus the relevant information need to be coerced into data frame using the `as.data.frame` method: ```{r table-opticut} kable(as.data.frame(oc)) ``` Single species result is a data frame: ```{r table-opticut1} kable(oc$species[[1]], digits=3) ``` ## Plots Visualizing the results: ```{r figure} plot(oc) ``` ## Quantifying uncertainty ```{r uncertainty} uc <- uncertainty(oc, type = "asymp", B = 999) summary(uc) ``` The opticut object and its summary are lists, thus the relevant information need to be coerced into data frame using the `as.data.frame` method: ```{r table-uncertainty} kable(as.data.frame(uc)) ```