Skip to contents

Note that if the column order is set in the xlsform choice part, the variable will be de factor considered as ordinal and the default ordering will not be done based on frequency

Usage

plot_select_one(
  datalist,
  dico,
  var,
  datasource = NULL,
  n = NULL,
  showcode = FALSE
)

Arguments

datalist

An object of the "datalist" class as defined in kobocruncher

dico

An object of the "kobodico" class format as defined in kobocruncher

var

name of the variable to display

datasource

name of the data source to display, if set to NULL - then pulls the form_title within the settings of the xlsform

n

if not NULL, lumps all levels except for the n most frequent (or least frequent if n < 0) - cf forcats::fct_lump_n()

showcode

display the code

Examples

dico <- kobo_dico( xlsformpath = system.file("sample_xlsform.xlsx", package = "kobocruncher") )
datalist <- kobo_data(datapath = system.file("data.xlsx", package = "kobocruncher") )

plot_select_one(datalist = datalist,
              dico = dico, 
              var = "profile.country",
              showcode = TRUE)
#> 
#> What is your country of Origin?
#> `plot_select_one(datalist, dico, "profile.country", datasource = params$datasource, n = 4)` 
#> 
#>  

## Exmaple with lumping
plot_select_one(datalist = datalist,
              dico = dico, 
              var = "profile.country",
              n = 1,
              showcode = TRUE)
#> 
#> What is your country of Origin?
#> `plot_select_one(datalist, dico, "profile.country", datasource = params$datasource, n = 1)` 
#> 
#>  


# plot_select_one(datalist = datalist,
#               dico = dico, 
#               var = "profile.countryerror",
#               showcode = TRUE)