I perform lots of data transformation and one of them makes me some troubles.
Let's assume that I have a dataset with variavles from v1 to v100, every one with numbers from 1 to 5. I want to recode/change some of variables (for example from v10 to v20)
I use dplyr package a lot and some another coming from Daniel Ludecke, i.e. sjmisc, sjPlot, sjlabelled etc.
dataset %>%
select(v10:v20) %>%
rec(rec = "1:2=1;3:5=2")
How to send the result of this operation to the initial dataset to the same place from which they were retrieved (this will be an overwrite)?
I don't want to create additional variable (i.e. v10_r, v11_r etc), just overwrite. I make a lot of these and similar changes to a dataset and would like to be able to apply them as simply as possible.
mutate,acrossandcase_whenshould get you goingdataset <- dataset %>% ,,,and if changing in-situ, look atacross()