簡體   English   中英

R制作具有不同分類級別的因子表對數線性模型

[英]R making a table of factors with different categorical levels log linear model

這是我嘗試制作表格的代碼:

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 infounexpected '=' after info 我的教授在課堂上做了一個這樣的例子,他的代碼有效。 我正在嘗試對數據進行對數線性模型

刪除+ 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 控制台中復制/粘貼代碼的回顯,但會給您帶來語法錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM