Cast a column of a cognostics data frame as a cognostic object

cog(
  val = NULL,
  desc = "",
  group = "common",
  type = NULL,
  default_label = FALSE,
  default_active = TRUE,
  filterable = TRUE,
  sortable = TRUE,
  log = NULL
)

Arguments

val

a scalar value (numeric, character, date, etc.)

desc

a description for this cognostic value

group

optional categorization of the cognostic for organizational purposes in the viewer (currently not implemented in the viewer)

type

the desired type of cognostic you would like to compute (see details)

default_label

should this cognostic be used as a panel label in the viewer by default?

default_active

should this cognostic be active (available for sort / filter / sample) by default?

filterable

should this cognostic be filterable? Default is TRUE. It can be useful to set this to FALSE if the cognostic is categorical with many unique values and is only desired to be used as a panel label.

sortable

should this cognostic be sortable?

log

when being used in the viewer for visual univariate and bivariate filters, should the log be computed? Useful when the distribution of the cognostic is very long-tailed or has large outliers. Can either be a logical or a positive integer indicating the base.

Value

object of class "cog"

Details

Different types of cognostics can be specified through the type argument that will affect how the user is able to interact with those cognostics in the viewer. This can usually be ignored because it will be inferred from the implicit data type of val. But there are special types of cognostics, such as geographic coordinates and relations (not implemented) that can be specified as well. Current possibilities for type are "key", "integer", "numeric", "factor", "date", "time", "href".

Examples

#> #> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
#> #> Attaching package: ‘plotly’
#> The following object is masked from ‘package:ggplot2’: #> #> last_plot
#> The following object is masked from ‘package:stats’: #> #> filter
#> The following object is masked from ‘package:graphics’: #> #> layout
mpg_cog <- mpg %>% nest(data = !one_of(c("manufacturer", "class"))) %>% mutate( cogs = map_cog(data, ~ tibble( mean_city_mpg = cog(mean(.$cty), desc = "Mean city mpg"), mean_hwy_mpg = cog(mean(.$hwy), desc = "Mean highway mpg"), most_common_drv = cog(tail(names(table(.$drv)), 1), desc = "Most common drive type") )), panel = map_plot(data, function(x) { plot_ly(data = x, x = ~cty, y = ~hwy, type = "scatter", mode = "markers") %>% layout( xaxis = list(range = c(9, 47)), yaxis = list(range = c(7, 37))) }) ) trelliscope(mpg_cog, name = "city_vs_highway_mpg", nrow = 1, ncol = 2)
#> Warning: `arrange_()` is deprecated as of dplyr 0.7.0. #> Please use `arrange()` instead. #> See vignette('programming') for more help #> This warning is displayed once every 8 hours. #> Call `lifecycle::last_warnings()` to see where this warning was generated.