tests/testthat/test_utils_vars_from_formula.R

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"))
})
madlogos/aseshms documentation built on May 21, 2019, 11:03 a.m.