tidy_marginals: Convert Marginals to Tidy (Molten) Data Frame

View source: R/eratosthenes.R

tidy_marginalsR Documentation

Convert Marginals to Tidy (Molten) Data Frame

Description

Takes the results of gibbs_ad or gibbs_ad_use and "melts" the list into a tidy data frame \insertCitewickham_tidy_2014eratosthenes. Each row of the molten data frame will contain the index of the Monte Carlo sample, the sample itself, and then the event name.

Usage

tidy_marginals(input)

## S3 method for class 'marginals'
tidy_marginals(input)

## S3 method for class 'use_marginals'
tidy_marginals(input)

Arguments

input

An object of class marginals or use_marginals, the output of gibbs_ad or gibbs_ad_use.

Value

A data frame giving the MC sampling index (idx), the sample (year), and the event (event).

References

\insertAllCited

Examples

x <- c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- c("B", "D", "G", "H", "K")
z <- c("F", "K", "L", "M")

contexts <- list(x, y, z)

f1 <- list(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- list(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- list(id = "find03", assoc = "G", type = c("type1", "form1"))
f4 <- list(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- list(id = "find05", assoc = "I", type = "type2")
f6 <- list(id = "find06", assoc = "H", type = NULL)

artifacts <- list(f1, f2, f3, f4, f5, f6)
 
# external constraints
coin1 <- list(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- list(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- list(id = "destr", assoc = "J", type = NULL, samples = 79)

tpq_info <- list(coin1, coin2)
taq_info <- list(destr)

result <- gibbs_ad(contexts, finds = artifacts, tpq = tpq_info, taq = taq_info)

tidy_marginals(result)


eratosthenes documentation built on June 28, 2025, 1:08 a.m.