Hi,
I have a dataset where I have combined surveys that happened for baseline and endline. But I need to differentiate it by adding suffix to variable names. For baseline, the _b
. has to be added. Then for endline, _e
has to be added.
Here in the reprex, from c1_identify_pic1
to el2_sent2
, _b
needs to be added. Then after that the variables repeat themselves. For them _e
has to be added. How can I do this?
library(tidyverse)
data<-tibble::tribble(
~student_id, ~c1_identify_pic1, ~c1_identify_pic2, ~c1_identify_pic3, ~c1_identify_pic4, ~c2_identify_col1, ~c2_identify_col2, ~c3_identify_shap1, ~c3_identify_shap2, ~el1_recog1, ~el2_sent1, ~el2_sent2, ~c1_identify_pic1, ~c1_identify_pic2, ~c1_identify_pic3, ~c1_identify_pic4, ~c2_identify_col1, ~c2_identify_col2, ~c3_identify_shap1, ~c3_identify_shap2, ~el1_recog1, ~el2_sent1, ~el2_sent2,
"DFGHG", 1L, 6L, 5L, 4L, 3L, 2L, 3L, 6L, 6L, 2L, 2L, 5L, 2L, 6L, 6L, 4L, 3L, 5L, 5L, 2L, 0L, 5L,
"DBFF", 6L, 5L, 4L, 0L, 4L, 6L, 4L, 3L, 2L, 3L, 3L, 2L, 3L, 5L, 3L, 6L, 6L, 0L, 3L, 6L, 4L, 4L,
"NDH", 5L, 3L, 0L, 0L, 1L, 0L, 0L, 4L, 4L, 4L, 1L, 6L, 6L, 6L, 2L, 6L, 4L, 6L, 6L, 5L, 4L, 0L,
"BSJJFK", 4L, 3L, 4L, 1L, 1L, 3L, 5L, 1L, 6L, 5L, 2L, 2L, 5L, 1L, 5L, 6L, 0L, 6L, 6L, 5L, 5L, 1L,
"BNSKII", 2L, 2L, 2L, 1L, 4L, 2L, 0L, 6L, 2L, 1L, 2L, 1L, 3L, 0L, 4L, 2L, 6L, 3L, 1L, 4L, 2L, 6L,
"BBD56", 2L, 6L, 0L, 1L, 0L, 5L, 4L, 2L, 5L, 0L, 1L, 0L, 6L, 6L, 2L, 6L, 6L, 2L, 6L, 6L, 0L, 3L,
"BBDJD", 5L, 0L, 2L, 3L, 5L, 4L, 1L, 6L, 2L, 1L, 5L, 2L, 2L, 1L, 0L, 6L, 3L, 0L, 2L, 2L, 1L, 2L
)