0

鉴于以下设置:

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)))
4

1 回答 1

3

添加ftablewitll 尝试将 pop.area.region 强制转换为ftable class. 这里不需要添加ftable,因为 pop.area.region 已经是一个 ftable。

identical(ftable(prop.table(pop.area.region,margin=2)),
                 prop.table(pop.area.region,margin=2))
TRUE
于 2013-05-25T11:40:21.740 回答