R制作具有不同分类级别的因子表记录线性模型

时间:2016-04-04 21:17:07

标签: r glm

这是我的代码试图制作一个表:

table <- data.frame(expand.grid(
    health = factor(c("support", "oppose"), levels = c("support", "oppose")), + 
    information = factor(c("support", "oppose"), levels = c("support", "oppose")), + 
    gender = factor(c("male", "female"), levels = c("support", "oppose")), 
                    count = c(76, 160, 6, 25, 114, 181,  11, 48)))

R说unexpected '=' after info。我的教授在课堂上做了一个这样的例子,他的代码很有效。我正在尝试做一个数据的对数线性模型

1 个答案:

答案 0 :(得分:0)

删除+ s:

table<- data.frame(expand.grid(health=factor(c("support", "oppose"), 
 levels=c("support", "oppose")), information = factor(c("support", 
"oppose"), levels=c("support", "oppose")), gender = factor(c("male", 
"female"), levels=c("support", "oppose")), count=c(76, 160, 6, 25, 114,
 181,  11, 48)))

它们可能来自复制/粘贴R控制台中代码的回显,但是会出现语法错误。