数据量很大,我知道检查列中所有变量的唯一方法是使用sapply
或str()
,两者都返回了55个状态。然而,情节只显示了8个州。
我没有听说过R为了方便而删除了额外的传说。任何人都可以告诉我什么似乎是一个问题?提前谢谢。
brfss2013_temp <- brfss2013 %>%
select(misnervs, mishopls, misdeprd, misrstls, miseffrt, miswtles, employ1, X_state) %>%
filter(!is.na(misnervs), !is.na(mishopls), !is.na(misdeprd), !is.na(misrstls),
!is.na(miseffrt), !is.na(miswtles), as.numeric(misnervs) <= 5,
as.numeric(mishopls) <= 5, as.numeric(misdeprd) <= 5, as.numeric(misrstls) <= 5,
as.numeric(miseffrt) <= 5, as.numeric(miswtles) <= 5)
brfss2013_temp$misnervs <- as.numeric(brfss2013_temp$misnervs)
brfss2013_temp$mishopls <- as.numeric(brfss2013_temp$mishopls)
brfss2013_temp$misdeprd <- as.numeric(brfss2013_temp$misdeprd)
brfss2013_temp$misrstls <- as.numeric(brfss2013_temp$misrstls)
brfss2013_temp$miseffrt <- as.numeric(brfss2013_temp$miseffrt)
brfss2013_temp$miswtles <- as.numeric(brfss2013_temp$miswtles)
brfss2013_temp$misrep <- rowMeans(brfss2013_temp[1:6])
sapply(brfss2013_temp, levels)
ggplot(data = brfss2013_temp,
mapping = aes(x = misrep, colour = X_state)) +
geom_freqpoly(binwidth = 0.2) +
labs(x = 'frequency of feeling negative in recent month, 1(all) - 5(none)',
colour = 'state')
ggplot(data = brfss2013_temp,
mapping = aes(x = misrep, colour = employ1)) +
geom_freqpoly(binwidth = 0.2) +
labs(x = 'frequency of feeling negative in recent month, 1(all) - 5(none)',
colour = 'employment type')