Code works but doesn't stay when I run the next step in the code

Try this. I think you didn't assign the result of ashes_study to a variable when you did it.


ashes_study <-cbind(ashes_long,ashes_match)

ashes_study <- ashes_study %>% 
    rename(ashes_study, scored = `3` , balls = `4` )
# you could also do filter out your NA values here, 

It would be good if you could provide a reproducible example though.