Introduction

This is a small example demonstrating how to include opticut results into Rmarkdown (Rmd) documents.

library(opticut)
library(knitr)
ocoptions(cut=-Inf)

Analysis

Data set

We have the following data set:

## 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:

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:

kable(as.data.frame(oc))

Single species result is a data frame:

kable(oc$species[[1]], digits=3)

Plots

Visualizing the results:

plot(oc)

Quantifying 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:

kable(as.data.frame(uc))


psolymos/opticut documentation built on Nov. 27, 2022, 11:29 a.m.