I am trying to fill in some missing data in my data frame, which looks like:
ID Value
1234 0001A
Text Text 2
1235 0001A
1236 0001A
Text Text 2
1237 0001A
1238 0001A
1239 0001A
Text Text 2
1240 0001A
What I want is after every numeric value in ID
I want to insert a Text
row, so the final result would be:
ID Value
1234 0001A
Text Text 2
1235 0001A
Text
1236 0001A
Text Text 2
1237 0001A
Text
1238 0001A
Text
1239 0001A
Text Text 2
1240 0001A
Text
I had found this answer and Ive tried adapting it to my requirements but no joy. Answer adding row based on presence of NA values
Example
df <- structure(list(ID = c("1234", "Text", "1235", "1236", "Text", "1237", "1238", "1239", "Text", "1240"), Value = structure(c(1L,
2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L), .Label = c("0001A", "Text 2"), class = "factor")), row.names = c(NA, -10L), class = "data.frame")
Note: ID column exists as a character element.