library(SAE)
##################
### Preliminary ###
##################
y <- c(1,2,3,4,1,2,3,4,1)
a <- as.factor(c(1,2,3,1,2,3,1,2,3))
b <- c(5,6,7,8,5,6,7,8,5)
df.survey <- data.frame(y, a, b)
str(df)
a.c <- as.factor(c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1))
b.c <- c(5,6,7,8,5,6,7,8,5,6,7,8,5,6,7,8)
df.census <- data.frame(a.c,b.c)
names(df.census) <- c("a", "b")
#c(6.5, 6.4, 6.6, 6.5, 6.4, 6.6, 6.5, 6.4, 6.6)
loc.mean <- aggregate(b ~ a, df.census, mean)
b.Cmean <- rep(loc.mean[,2], 3)
df.survey.new <-data.frame(a, y, b, b.Cmean)
df.survey.new <- df.survey.new[order(a),]
df.survey.new[,4]
mResponse<- c("b")
context("Testing of the function mean.for.regression.R")
test_that("the function returns nothing if a character vector is put in", {
expect_equal(as.data.frame(mean.for.regression(mResponse="b",
censusdata=df.census,
surveydata=df.survey,
model= y ~ a + b,
location_survey = "a")[[2]])[,4],df.survey.new[,4])
expect_equal(mean.for.regression(mResponse="b",
censusdata=df.census,
surveydata=df.survey,
model= y ~ a + b,
location_survey = "a")[[1]],
"y ~ a + b + b.Cmean")
expect_equal(is.list(mean.for.regression(mResponse="b",
censusdata=df.census,
surveydata=df.survey,
model= y ~ a + b,
location_survey = "a")),
TRUE)
expect_equal(ncol(as.data.frame(mean.for.regression(mResponse="b",
censusdata=df.census,
surveydata=df.survey,
model= y ~ a + b,
location_survey = "a")[[2]])),
ncol(df.survey)+length(mResponse))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.