I am grouping the data and then summing it up, but would also like to keep another column. I do not need to make any evaluations of the contents of this column, since it will always be the same as the group_by column. I can add it to the group_by statement, but this does not seem to be "correct". I want to save State.Full.Nameafter grouping State. Thanks
TDAAtest <- data.frame(State=sample(state.abb,1000,replace=TRUE))
TDAAtest$State.Full.Name <- state.name[match(TDAAtest$State,state.abb)]
TDAA.states <- TDAAtest %>%
filter(!is.na(State)) %>%
group_by(State) %>%
summarize(n=n()) %>%
ungroup() %>%
arrange(State)
source
share