I have data that look similar to:
Alabama Age>50 Value1 Value2 Value3
Age<50 Value1 Value2 Value3
Alaska Age>50 Value1 Value2 Value3
Age<50 Value1 Value2 Value3
I only need to keep the data for Age<50
. How can I repeat the state name to the row below it? I have created a string of the state names, but am unsure how to insert it into every other row in the first column.
The head of my data.frame
is:
d <- structure(c("ALABAMA", "", "ALASKA", "", "ARIZONA", "", "Under 18",
"Total all ages", "Under 18", "Total all ages", "Under 18", "Total all ages",
"0", "1", "10", "87", "46", "303", "0", "0", "0", "36", "6", "855", "84,843",
"", "469,145", "", "6,303,555", ""), .Dim = c(6L, 5L), .Dimnames = list(NULL,
c("State", "", "Rape3", "Prostitution and\ncommercialized\nvice",
"2014\nestimated \npopulation")))