Hi I am trying to work out the mode for each unique ID.
In other words, I would like to know the mode for each household_key for DAY, TRANS_TIME, WEEK_NO. i.e. on which day each household appears the most etc.
I have put together some code
library(dplyr)
randomtest <- mydata %>% group_by(household_key) %>%
summarise_each(funs(mode),DAY, TRANS_TIME, WEEK_NO)
This outputs:
household_key DAY TRANS_TIME WEEK_NO
1 1 numeric numeric numeric
2 2 numeric numeric numeric
3 3 numeric numeric numeric
4 4 numeric numeric numeric
5 5 numeric numeric numeric
6 6 numeric numeric numeric
7 7 numeric numeric numeric
8 8 numeric numeric numeric
9 9 numeric numeric numeric
10 10 numeric numeric numeric
I understand numeric means decimals? Does that mean my answers are in decimals if so how I can change it to round up the value and display me a number?
Below is sample of my dataframe <- mydata
household_key DAY TRANS_TIME WEEK_NO
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
2375 1 6 1
1364 1 6 1
1364 1 6 1
1364 1 6 1
1364 1 6 1
1364 1 6 1
1130 1 5 1
1130 1 5 1
1130 1 5 1
1130 1 5 1
1130 1 5 1
1173 1 7 1
1173 1 7 1
1173 1 7 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1
1172 1 4 1