context("Test utils_vars_from_formula")
test_that("parse formula", {
in11 <- "y+z~x*w+m|d"
in12 <- y+z~x*w+m|d
in13 <- y+z~x+m*w|d
in14 <- y+z~x*ww|d+m*w
out1 <- c(x="x + m", y="y + z", series="d", weight="w")
in2 <- "y~."
out2 <- c(x=".", y="y", series=NA, weight=NA)
expect_equal(parse_formula(in11), out1)
expect_equal(parse_formula(in12), out1)
expect_equal(parse_formula(in13), out1)
expect_equal(suppressWarnings(parse_formula(in14)), out1)
expect_warning(parse_formula(in14), "Only to extract the last")
expect_null(parse_formula(NULL))
expect_equal(parse_formula(y, x, s, wgt, z), c(x="y", y="x", series="s", weight="wgt"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.