I really need your help with processing this dataframe. Let's assume we have a dataframe like the one below.
category value
A NA
high 20
mid 18
low 10
B NA
high 22
mid 12
low 11
C NA
low 14
As you can see, there are 3 categories A, B, and with possible subcategories high, mid, low. The category names have NA value because only each category's subcategory has a value, not the category itself. What makes this complicated is the fact that category C has only a single subcategory, which is low. The format I would like to convert it to, looks something like this:
category subcategory value
A high 20
A mid 18
A low 10
B high 22
B mid 12
B low 11
C low 14
I would really appreciate if someone could help me with this. I have been trying to figure it out for a long while. Thanks!