. Can anyone help me convert the following dataset to a more tidy form?
## # A tibble: 3 x 5
## famid named incd namem incm
## <dbl> <chr> <dbl> <chr> <dbl>
## 1 1 Bill 30000 Bess 15000
## 2 2 Art 22000 Amy 18000
## 3 3 Paul 25000 Pat 50000
I’m aiming to convert it to the following form:
## # A tibble: 6 x 4
## famid parent name inc
## <dbl> <chr> <chr> <dbl>
## 1 1 d Bill 30000
## 2 1 m Bess 15000
## 3 2 d Art 22000
## 4 2 m Amy 18000
## 5 3 d Paul 25000
## 6 3 m Pat 50000
I’ve been trying to use pivot_longer
from the tidyr
package in R to achieve this, but keep receiving errors. Can anyone help me get this dataset into a more tidy form?