There is a dataset like this
df <- data.frame(
Pseudonym = c("aa", "bb"),
KE_date_1 = c("2022-04-01", "2022-04-03"),
KE_content_2 = c("high pot", "high pot"),
KE_date_3 = c("2022-08-01", "2022-08-04"),
KE_content_4 = c("high pot return", "high pot return")
)
Pseudonym | KE_date_1 | KE_content_2| KE_date_3 | KE_content_4
--------------------------------------------------------------------
aa | 2022-04-01| high pot | 2022-08-01 | high pot return
bb | 2022-04-03| high pot | 2022-08-04 | high pot return
A column with an identifier (distinct pseudonym) and pairwise data columns, date + text. The data columns have an increasinig suffix. ..1 and ..2 belong togethter, etc.
From this a transformed long dataset is needed, where the pseudonym is not longer distinct.
df2 <- data.frame(
Pseudonym = c("aa", "aa", "bb", "bb"),
KE_date = c("2022-04-01", "2022-08-01", "2022-04-03", "2022-08-04"),
KE_content = c("high pot", "high pot return", "high pot", "high pot return")
)
Pseudonym | KE_date | KE_content
-------------------------------------------
aa | 2022-04-01 | high pot
aa | 2022-08-01 | high pot return
bb | 2022-04-03 | high pot
bb | 2022-08-04 | high pot return
Can anyone help? Thank you.