Skip to contents

[Experimental]

Get data from an elic_cat object.

Usage

cat_get_data(x, topic, ..., option = "all")

Arguments

x

an object of class elic_cat.

topic

character string that indicates the mechanism to which the data belongs.

...

Unused arguments, included only for future extensions of the function.

option

character string with the name of the option or character vector with the options that you want to extract from the data. Use all for all options.

Value

A tibble with the extracted data.

See also

Other cat data helpers: cat_add_data(), cat_sample_data(), cat_start(), summary.cat_sample()

Author

Sergio Vignali

Examples

# Create the elic_cat object for an elicitation process with three topics,
# four options, five categories and a maximum of six experts per topic
my_categories <- c("category_1", "category_2", "category_3",
                   "category_4", "category_5")
my_options <- c("option_1", "option_2", "option_3", "option_4")
my_topics <- c("topic_1", "topic_2", "topic_3")
my_elicit <- cat_start(categories = my_categories,
                       options = my_options,
                       experts = 6,
                       topics = my_topics) |>
  cat_add_data(data_source = topic_1, topic = "topic_1") |>
  cat_add_data(data_source = topic_2, topic = "topic_2") |>
  cat_add_data(data_source = topic_3, topic = "topic_3")
#>  <elic_cat> object for "Elicitation" correctly initialised
#>  Data added to Topic "topic_1" from "data.frame"
#>  Data added to Topic "topic_2" from "data.frame"
#>  Data added to Topic "topic_3" from "data.frame"

# Get all data from Topic 1
cat_get_data(my_elicit, topic = "topic_1")
#> # A tibble: 120 × 5
#>    id      category   option   confidence estimate
#>    <chr>   <chr>      <chr>         <dbl>    <dbl>
#>  1 5ac97e0 category_1 option_1         15     0.08
#>  2 5ac97e0 category_2 option_1         15     0   
#>  3 5ac97e0 category_3 option_1         15     0.85
#>  4 5ac97e0 category_4 option_1         15     0.02
#>  5 5ac97e0 category_5 option_1         15     0.05
#>  6 5ac97e0 category_1 option_2         35     0.02
#>  7 5ac97e0 category_2 option_2         35     0.11
#>  8 5ac97e0 category_3 option_2         35     0.18
#>  9 5ac97e0 category_4 option_2         35     0.02
#> 10 5ac97e0 category_5 option_2         35     0.67
#> # ℹ 110 more rows

# Get data by option name----
# Get data for option_1 from Topic 2
cat_get_data(my_elicit, topic = "topic_2", option = "option_1")
#> # A tibble: 25 × 5
#>    id      category   option   confidence estimate
#>    <chr>   <chr>      <chr>         <dbl>    <dbl>
#>  1 e51202e category_1 option_1        100     0.09
#>  2 e51202e category_2 option_1        100     0.21
#>  3 e51202e category_3 option_1        100     0.11
#>  4 e51202e category_4 option_1        100     0.59
#>  5 e51202e category_5 option_1        100     0   
#>  6 e78cbf4 category_1 option_1         75     0.31
#>  7 e78cbf4 category_2 option_1         75     0.27
#>  8 e78cbf4 category_3 option_1         75     0.09
#>  9 e78cbf4 category_4 option_1         75     0.17
#> 10 e78cbf4 category_5 option_1         75     0.16
#> # ℹ 15 more rows

# Get data for option_1 and option_3 from Topic 3
cat_get_data(my_elicit,
             topic = "topic_3",
             option = c("option_1", "option_3"))
#> # A tibble: 60 × 5
#>    id      category   option   confidence estimate
#>    <chr>   <chr>      <chr>         <dbl>    <dbl>
#>  1 5ac97e0 category_1 option_1         80     0.02
#>  2 5ac97e0 category_2 option_1         80     0.02
#>  3 5ac97e0 category_3 option_1         80     0.01
#>  4 5ac97e0 category_4 option_1         80     0.87
#>  5 5ac97e0 category_5 option_1         80     0.08
#>  6 5ac97e0 category_1 option_3         15     0.59
#>  7 5ac97e0 category_2 option_3         15     0.08
#>  8 5ac97e0 category_3 option_3         15     0.11
#>  9 5ac97e0 category_4 option_3         15     0   
#> 10 5ac97e0 category_5 option_3         15     0.22
#> # ℹ 50 more rows