You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
296 B
R
12 lines
296 B
R
5 years ago
|
# Goal: R syntax where model specification is an argument to a function.
|
||
|
|
||
|
# Invent a dataset
|
||
|
x <- runif(100); y <- runif(100); z <- 2 + 3*x + 4*y + rnorm(100)
|
||
|
D <- data.frame(x=x, y=y, z=z)
|
||
|
|
||
|
amodel <- function(modelstring) {
|
||
|
summary(lm(modelstring, D))
|
||
|
}
|
||
|
|
||
|
amodel(z ~ x)
|
||
|
amodel(z ~ y)
|