I have the following dataframe:
tibble(year = c("2020Q1", "2020Q2", "2020Q3", "2020Q4", "2020END","2020Q1", "2020Q2", "2020Q3", "2020Q4", "2020Q1","2020Q2", "2020Q3", "2020Q4", "2020END"),
website = c("google","google","google","google","google", "facebook","facebook","facebook","facebook","youtube","youtube","youtube","youtube", "youtube"),
something = c(1,2,3,4,5,6,7,8,9,10,11,12,13, 14)
)
How can i make such a condition so that:
When Q4 and END are mentioned for the same website, then to take only the END values - but this is not the case only take Q4 values?
Desired output is the following table:
tibble(year = c("2020Q1", "2020Q2", "2020Q3","2020END","2020Q1", "2020Q2", "2020Q3", "2020Q4", "2020Q1","2020Q2", "2020Q3", "2020END"),
website = c("google","google","google","google", "facebook","facebook","facebook","facebook","youtube","youtube","youtube","youtube"),
something = c(1,2,3,5,6,7,8,9,10,11,12, 14)
)
I have tried using filter()
but i assume there is a better condition, maybe pivoting? Assume I am not working with dates in the year column - as it really is only the string i am searching for Q4 and END to occur