I have some textual data which presents itself in the following format after being read into R:
> lst <- list('A', c("", 'aa'), 'bb', 'cc', 'B', c("", 'aa'), 'bb', 'cc', 'dd')
[[1]]
[1] "A"
[[2]]
[1] "" "aa"
[[3]]
[1] "bb"
[[4]]
[1] "cc"
[[5]]
[1] "B"
[[6]]
[1] "" "aa"
[[7]]
[1] "bb"
[[8]]
[1] "cc"
[[9]]
[1] "dd"
Is there an easy way to change the structure of this list using "" as an indicator, so that the item immediately before "" becomes a list heading?
lst2 <- list(A=c('aa', 'bb', 'cc'), B=c('aa', 'bb', 'cc', 'dd'))
$A
[1] "aa" "bb" "cc"
$B
[1] "aa" "bb" "cc" "dd"