How to convert wide-data to long-data format for big dataset?

  Kiến thức lập trình

I am conducting a cross-sectional online study about 54 illnesses, and have 10 variables/columns for participants’ background information, then participants were randomly assigned to a set of 9 different illnesses (for each illness I had 20 questions, with the beginning of the columnname signifiying the kind of illness : epi_fam, epi_exp..; ms_fam, ms_exp., autism_fam, autism_exp etc.).

I am trying to convert the data from wide to long format in an efficient way, so that I have a new column indicating the kind of illness, but I am not sure how to do that.

Does someone have an idea ?

Thanks in advance!

L

I tried it using pivotlonger function of tidyr but I do not manage the thing with the illness column names.

New contributor

Lea is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT