Learn R Programming

datadr (version 0.8.6.1)

bsv: Construct Between Subset Variable (BSV)

Description

Construct between subset variable (BSV)

For a given key-value pair, get a BSV variable value by name (if present)

Usage

bsv(val = NULL, desc = "")

getBsv(x, name)

getBsvs(x)

Arguments

val

a scalar character, numeric, or date

desc

a character string describing the BSV

x

a key-value pair or a value

name

the name of the BSV to get d <- divide(iris, by = "Species", bsvFn = function(x) list(msl = bsv(mean(x$Sepal.Length)))) getBsvs(d[[1]]$value) getBsv(d[[1]]$value, "msl")

Details

Should be called inside the bsvFn argument to divide used for constructing a BSV list for each subset of a division.

See Also

divide, getBsvs, bsvInfo

Examples

Run this code
# NOT RUN {
irisDdf <- ddf(iris)

bsvFn <- function(dat) {
  list(
    meanSL = bsv(mean(dat$Sepal.Length), desc = "mean sepal length"),
    meanPL = bsv(mean(dat$Petal.Length), desc = "mean petal length")
  )
}

# divide the data by species
bySpecies <- divide(irisDdf, by = "Species", bsvFn = bsvFn)
# see BSV info attached to the result
bsvInfo(bySpecies)
# get BSVs for a specified subset of the division
getBsvs(bySpecies[[1]])

# }

Run the code above in your browser using DataLab