Often times I get data in the format of an excel spreadsheet that looks like:
Name1 Data
Data
Data
Name2 Data
Data
Data
....
When I read this into R, the blank rows come us as NA and then I always write some ad hoc code to fill it in so that it looks like:
Name1 Data
Name1 Data
Name1 Data
Name2 Data
Name2 Data
Name2 Data
....
Typically, I just do this with a for loop that keeps track of the last name and every time I see an NA I fill it in. The next time I see something in the name column, I then save the new name and start writing that.
I was wondering if there was a prettier, R vectorized version of that?
Thanks!