I have a data that looks like below in excel 2007.
Class Var1 Var2
1 20 27
2 13
2
2 11
2
1 11 27
2 61
2
2
2
1 20 27
2 30 71
2
2
All Class=2 are individuals that are a member of the household (Class=1) directly above it. From may example, this data belongs to one household
Class Var1 Var2
1 20 27
2 13
2
2 11
2
What I would like to do is remove the data in the individual level and replace it with value of the household level. So from my example, the output should be,
Class Var1 Var2
1 20 27
2 20 27
2 20 27
2 20 27
2 20 27
Is there an easy way to do this in excel or in R? I have 200k+ rows of data so doing it manually would take me forever.
I am not sure how to remove the values in the individual level. But once that can be done, I can just use excels Go to > Special > Blanks functions.
Thanks Dixi
I'm reading in your data as under -
And then processing it as below -
To get the output -
If you read the data into R
data.frame
sayDF
. Then you can just reset values ofVar1
andVar2
toNA
first then usena.locf
function from packagezoo