tests/testthat/test-factors.R

library("testthat")
library("lme4")

context("factor handling in grouping variables")

test_that("factors", {

    set.seed(101)
    d <- data.frame(x=runif(1000),y=runif(1000),f1=rep(1:10,each=100),f2=rep(1:10,100))
    d2 <- transform(d,f1=factor(f1),f2=factor(f2))
    expect_that(lm1 <- lmer(y~x+(1|f1/f2),data=d), is_a("lmerMod"))
    expect_that(lm2 <- lmer(y~x+(1|f1/f2),data=d2),is_a("lmerMod"))
    expect_equivalent(lm1,lm2)

})

Try the lme4 package in your browser

Any scripts or data that you put into this service are public.

lme4 documentation built on April 4, 2018, 1:04 a.m.