One of the columns in my dataset is "Movement_Stats", it contains "forward", "backward" and "Stop". Each row represents an image frame. So this column looks like: "forward, forward, forward, backward, forward, forward...". I want to smooth the categorical values of this column by the rule:
- For each row, check its previous 5 rows and next 5 rows (its neighbor)
- Re-assign the value of this row by the MAJORITY VOTE of its neighbor
I did not find any package I can use in R.