Hi there! I have something like this:
example <- data.frame(country=c("Argentina","Uruguay"),
date1=c("14-feb","15-feb"),
value1=c(12,15),
date2=c("16-feb","17-feb"),
value2=c(10,15))
But i would like to have something like this:
result <- data.frame(country=c("Argentina","Uruguay","Argentina","Uruguay"),date=c("14-feb","15-feb","16-feb","17-feb"),value=c(12,15,10,15))
I have around 300 dates and numbers that need to be matched and gathered as rows, since they are samples and not variables. I usually use somthing like this:
result <- bind_rows(
example %>% select(country,date=date1,value=value1),
`example %>% select(country,date=date2,value=value2),
example %>% select(country,date=date3,value=value3),
But this time i have so many of them that i was wondering if there is any way to do this with a function. I tryied to do it but couldnt make it, I am not really good with non mathematical functions.
What would you recommend me to do?
Thank you!