Hallo again R comunity,
I am stucked with a very easy problem to solve with excel, but I would love to learn the solution using R.
df = data.frame(pt_name=c("mario","NA","NA","luigi","NA","NA","toad","NA","NA"),
pod=rep(c(1,2,3),3),
crea=c(0.4,0.5,0.4,1,2,2.5,4,4.5,6),
other_value=rep(c(NA),9))
that gives me
> df
pt_name pod crea other_value
1 mario 1 0.4 NA
2 NA 2 0.5 NA
3 NA 3 0.4 NA
4 luigi 1 1.0 NA
5 NA 2 2.0 NA
6 NA 3 2.5 NA
7 toad 1 4.0 NA
8 NA 2 4.5 NA
9 NA 3 6.0 NA
My goal is to convert it to this format
df = data.frame(pt_name=c("mario","mario","mario","luigi","luigi","luigi","toad","toad","toad"),
pod=rep(c(1,2,3),3),
crea=c(0.4,0.5,0.4,1,2,2.5,4,4.5,6),
other_value=rep(c(NA),9))
that is
pt_name pod crea other_value
1 mario 1 0.4 NA
2 mario 2 0.5 NA
3 mario 3 0.4 NA
4 luigi 1 1.0 NA
5 luigi 2 2.0 NA
6 luigi 3 2.5 NA
7 toad 1 4.0 NA
8 toad 2 4.5 NA
9 toad 3 6.0 NA
( basically fulfill the pt_name column with the names)
thanks a lot for your help!