最佳答案
我试图用 dplyr 管道从子集中移除 NA。我的回答是否意味着我错过了一步。我正在学习如何使用 dplyr 编写函数:
> outcome.df%>%
+ group_by(Hospital,State)%>%
+ arrange(desc(HeartAttackDeath,na.rm=TRUE))%>%
+ head()
Source: local data frame [6 x 5]
Groups: Hospital, State
Hospital State HeartAttackDeath 1 ABBEVILLE AREA MEDICAL CENTER SC NA 2 ABBEVILLE GENERAL HOSPITAL LA NA 3 ABBOTT NORTHWESTERN HOSPITAL MN 12.3 4 ABILENE REGIONAL MEDICAL CENTER TX 17.2 5 ABINGTON MEMORIAL HOSPITAL PA 14.3 6 ABRAHAM LINCOLN MEMORIAL HOSPITAL IL NA Variables not shown: HeartFailureDeath (dbl), PneumoniaDeath (dbl)