I’m trying to get the number of locations per date and nothing is working for me.
Date | Location |
---|---|
1 | SNF |
1 | IRF |
1 | HHA |
2 | IRF |
2 | SNF |
3 | IRF |
3 | HHA |
3 | IRF |
I want
Date | N_SNF | N_IRF | N_HHA |
---|---|---|---|
1 | 1 | 1 | 1 |
2 | 1 | 1 | 1 |
2 | 0 | 1 | 2 |
summary <- ddply(data, “Date”, summarize, N_SNF=length(data$Location == “SNF”))
- gives total number of rows in data frame, not how many SNFs per date
summary <- ddply(data, “Date”, summarize, N_SNF=sum(data$Location == “SNF”))
- gives total number of SNFs in data frame, not how many SNFs per date
summary <- ddply(data, “Date”, summarize, N_SNF=count(data$Location == “SNF”))
- gives Error in quickdf(.data[names(cols)]) : length(rows) == 1 is not TRUE
summary <- ddply(data, “Date”, summarize, N_SNF=n(data$Location == “SNF”))
- gives Error in n(data$FollowUp == “SNF”) : unused argument (data$Location == “SNF”)