给出以下设置:
area.factor <- cut(state.x77[,"Area"],
breaks=quantile(state.x77[,"Area"],c(0,.25,.75,1)),
labels=c("small","medium","large"),
include.lowest=TRUE)
state <- data.frame(pop=state.x77[,"Population"],
inc=state.x77[,"Income"],
area=area.factor,
region=state.region)
pop.area.region <- with(state,ftable(pop,area,region))
以下两行代码显示相同的结果:
head(ftable(prop.table(pop.area.region,margin=2)))
head(prop.table(pop.area.region,margin=2))
我不明白添加ftable
有什么影响,如果有的话:
head(ftable(prop.table(pop.area.region,margin=2)))
答案 0 :(得分:3)
添加ftable
会尝试将pop.area.region强制转换为ftable class
。这里
无需添加ftable
,因为pop.area.region已经是一个f表。
identical(ftable(prop.table(pop.area.region,margin=2)),
prop.table(pop.area.region,margin=2))
TRUE