0

Below is the example of my data :

Parents Age Child1 Child2 Child2
Adrian 42 santos Jennie NA
Barbar 32 michel briane Celloy
Celice 29 pierre NA NA

The goal is to create only 3 columns (Parents, Age and Child) like the example below :

Parents Age Childs
Adrian 42 santos
Adrian 42 Jennnie
Barbar 32 michel
Barbar 32 briane
Barbar 32 celloy
Celice 29 pierre

An observation contains only one child from one parents If parents have more than one child, the other child will be displayed on the next row.

Coul you help me to solve this problem please ? Because i'm really beginner in R Thank you very much for your assistance!

Shadow
  • 33,525
  • 10
  • 51
  • 64
R_user
  • 13
  • 4
  • `tidyr::pivot_longer(cols = dplyr::contains("Child"), names_to = "names", values_to = "Child", values_drop_na = TRUE)` – Julian Jan 25 '23 at 16:32

0 Answers0