Hello all,
I hope someone can provide me with a great solution to my problem:
Say I have a data frame with columns: Activity and Date
I want to create a new column called Coding that's value is "G" if the row has Activity == "Game" or make the value "G1" if the row has a Date of 1 less than the date for a row with Activity == "Game". "G2" if it is 2 days before....and so on
So, basically I am looking for a way to conditionally add a column based on the two columns: Activity and Date. I feel like date labeling is popular and maybe there is something out there already that knows how to label something based on days away from that target date.
The basic structure would look like:
activity <- c("Game", "Practice", "Game", "Practice")
date <- c("02/19/2019", "02/21/2019", "02/22/2019", "02/23/2019")
df <- data.frame(activity,date)
I would need to make df$coding == "G" or "G1" or "G2" or "G3"....etc. based on the above conditions
Thank you.