Skip to contents

[Stable]

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.

Author

Sergio Vignali and Maude Vernet

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_topics <- c("topic_1", "topic_2", "topic_3")
my_options <- c("option_1", "option_2", "option_3", "option_4")
my_categories <- c("category_1", "category_2", "category_3",
                   "category_4", "category_5")
my_elicit <- cat_start(topics = my_topics,
                       options = my_options,
                       categories = my_categories,
                       experts = 6) |>
  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
#> ℹ Estimates sum to 1. Rescaling to 100.
#> ✔ Data added to Topic "topic_1" from "data.frame"
#> ℹ Estimates sum to 1. Rescaling to 100.
#> ✔ Data added to Topic "topic_2" from "data.frame"
#> ℹ Estimates sum to 1. Rescaling to 100.
#> ✔ 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      option   category   confidence estimate
#>    <chr>   <chr>    <chr>           <dbl>    <dbl>
#>  1 5ac97e0 option_1 category_1         66       57
#>  2 5ac97e0 option_1 category_2         66       18
#>  3 5ac97e0 option_1 category_3         66        2
#>  4 5ac97e0 option_1 category_4         66        2
#>  5 5ac97e0 option_1 category_5         66       21
#>  6 5ac97e0 option_2 category_1         86        6
#>  7 5ac97e0 option_2 category_2         86        4
#>  8 5ac97e0 option_2 category_3         86       12
#>  9 5ac97e0 option_2 category_4         86       42
#> 10 5ac97e0 option_2 category_5         86       36
#> # ℹ 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      option   category   confidence estimate
#>    <chr>   <chr>    <chr>           <dbl>    <dbl>
#>  1 e51202e option_1 category_1         86       28
#>  2 e51202e option_1 category_2         86       13
#>  3 e51202e option_1 category_3         86       55
#>  4 e51202e option_1 category_4         86        4
#>  5 e51202e option_1 category_5         86        0
#>  6 e78cbf4 option_1 category_1         71        5
#>  7 e78cbf4 option_1 category_2         71       20
#>  8 e78cbf4 option_1 category_3         71        7
#>  9 e78cbf4 option_1 category_4         71       47
#> 10 e78cbf4 option_1 category_5         71       21
#> # ℹ 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      option   category   confidence estimate
#>    <chr>   <chr>    <chr>           <dbl>    <dbl>
#>  1 5ac97e0 option_1 category_1         61       12
#>  2 5ac97e0 option_1 category_2         61       50
#>  3 5ac97e0 option_1 category_3         61       16
#>  4 5ac97e0 option_1 category_4         61        2
#>  5 5ac97e0 option_1 category_5         61       20
#>  6 5ac97e0 option_3 category_1         91       59
#>  7 5ac97e0 option_3 category_2         91        1
#>  8 5ac97e0 option_3 category_3         91        1
#>  9 5ac97e0 option_3 category_4         91       28
#> 10 5ac97e0 option_3 category_5         91       11
#> # ℹ 50 more rows