crunch (version 1.30.4)

filter: Get and set slide analyses

Description

Slides are composed of analyses, which are effectively CrunchCubes with some additional metadata. You can get and set a slide's Analysis Catalog with the analyses method, and access an individual analysis with analysis. There are also helpers to get and set the components of the analysis such as filter(), weight(), transforms(), displaySettings() and vizSpecs(). You can also get the CrunchCube from an analysis using cube().

Usage

filter(x, ...)

filter(x) <- value

# S4 method for CrunchDeck,ANY weight(x) <- value

# S4 method for CrunchDeck filter(x) <- value

# S4 method for CrunchDeck,ANY filters(x) <- value

# S4 method for CrunchAnalysisSlide transforms(x)

# S4 method for AnalysisCatalog transforms(x)

# S4 method for Analysis transforms(x)

# S4 method for CrunchAnalysisSlide,ANY transforms(x) <- value

# S4 method for AnalysisCatalog,ANY transforms(x) <- value

# S4 method for Analysis,ANY transforms(x) <- value

analyses(x)

analysis(x)

analysis(x) <- value

query(x) <- value

cube(x)

cubes(x)

displaySettings(x)

displaySettings(x) <- value

vizSpecs(x)

vizSpecs(x) <- value

# S4 method for CrunchSlide type(x)

# S4 method for CrunchAnalysisSlide analyses(x)

# S4 method for CrunchAnalysisSlide analysis(x)

# S4 method for CrunchAnalysisSlide,formula analysis(x) <- value

# S4 method for CrunchAnalysisSlide,Analysis analysis(x) <- value

# S4 method for CrunchAnalysisSlide,list analysis(x) <- value

# S4 method for CrunchAnalysisSlide filter(x, ...)

# S4 method for CrunchAnalysisSlide filters(x)

# S4 method for CrunchAnalysisSlide,ANY filters(x) <- value

# S4 method for CrunchAnalysisSlide,ANY query(x) <- value

# S4 method for CrunchAnalysisSlide cubes(x)

# S4 method for CrunchAnalysisSlide cube(x)

# S4 method for CrunchAnalysisSlide displaySettings(x)

# S4 method for CrunchAnalysisSlide,ANY displaySettings(x) <- value

# S4 method for CrunchAnalysisSlide vizSpecs(x)

# S4 method for CrunchAnalysisSlide,ANY vizSpecs(x) <- value

# S4 method for AnalysisCatalog cubes(x)

# S4 method for AnalysisCatalog displaySettings(x)

# S4 method for AnalysisCatalog,list displaySettings(x) <- value

# S4 method for AnalysisCatalog vizSpecs(x)

# S4 method for AnalysisCatalog,list vizSpecs(x) <- value

# S4 method for Analysis,formula query(x) <- value

formulaToSlideQuery(query, dataset)

# S4 method for Analysis cube(x)

# S4 method for Analysis displaySettings(x)

# S4 method for Analysis,ANY displaySettings(x) <- value

# S4 method for Analysis vizSpecs(x)

# S4 method for Analysis,ANY vizSpecs(x) <- value

# S4 method for Analysis filter(x, ...)

# S4 method for Analysis filters(x)

# S4 method for ANY filter(x, ...)

# S4 method for CrunchAnalysisSlide filter(x) <- value

# S4 method for Analysis filter(x) <- value

# S4 method for Analysis,CrunchLogicalExpr filters(x) <- value

# S4 method for Analysis,CrunchFilter filters(x) <- value

# S4 method for Analysis,`NULL` filters(x) <- value

# S4 method for Analysis,list filters(x) <- value

slideQueryEnv(weight, filter)

# S4 method for CrunchDeck cubes(x)

# S4 method for CrunchAnalysisSlide weight(x)

# S4 method for CrunchAnalysisSlide,ANY weight(x) <- value

# S4 method for Analysis weight(x)

Arguments

x

a CrunchSlide, AnalysisCatalog, or Analysis

...

ignored

value

for the setter, an object to set it

query

For formulaToSlideQuery(), a formula that specifies the query, as in newSlide(). See Details of crtabs() for more information.

dataset

For formulaToSlideQuery(), a CrunchDataset that the variables in query refer to.

weight

For slideQueryEnv() a crunch variable to use as a weight or NULL to indicate no weight should be used.

filter

for slideQueryEnv(), a CrunchFilter or CrunchExpression to filter the slide.

Details

For more complex objects like displaySettings(), vizSpecs() and transforms(), the API documentation provides more details.

Advanced users of the API can assign a list to analysis<- to specify settings on the analyses that are not otherwise available in rcrunch. The helpers formulaToSlideQuery() and slideQueryEnv() help you create objects for the query and query_environment.

Examples

Run this code
if (FALSE) {
# Examples of setting analysis details (in general these setters work on
# the slide, analysis catalog and analysis, but for brevity the examples only
# show on the slide)

# Change the filter
filters(slide) <- NULL # to remove a filter
filters(slide) <- filters(ds)[["My filter"]]
filters(slide) <- list( # Can set multiple filter
    filters(ds)[["My filter"]],
    ds$age_grp == "18-35"
)
filters(deck) <- filters(ds)[["My filter"]] # Can set the same filter on a whole deck too

# Change the weight
weight(slide) <- NULL # to remove
weight(slide) <- ds$weight
weight(deck) <- ds$weight # Can set the same weight on a whole deck too

# Change the transforms
transforms(slide) <- list(rows_dimension = makeDimTransform(hide = "Neutral"))

# Change the displaySettings
displaySettings(slide) <- list(vizType = "groupedBarPlot")

# Change the vizSpecs
# viz_specs can get quite long, see
# https://crunch.io/api/reference/#post-/datasets/-dataset_id-/decks/-deck_id-/slides/
vizSpecs(slide) <- viz_specs

# Change the query
#' query(slide) <- ~ cyl + wt
}

Run the code above in your browser using DataLab