Description Usage Arguments Details Value Examples
Cast a column of a cognostics data frame as a cognostic object
1 2 3 4 5 6 7 8 9 10 11 |
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 |
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. |
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".
object of class "cog"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(dplyr)
library(tidyr)
library(purrr)
library(ggplot2)
library(plotly)
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)
|
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
Warning message:
`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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.