How to convert the data.frame file
df <- data.frame(id=c("af1", "af2"), start=c(100, 115), end=c(114,121))
To the list of lists
LoL <- list(list(id="af1", start=100, end=114), list(id="af2", start=115, end=121))
I tried things like
not.LoL <- as.list(as.data.frame(t(df)))
and I'm really not sure what I can do after that, but this is not entirely correct. My requirement is that I can access, say, the first start using the command
> LoL[[1]]$start [1] 100
the not.LoL that I am not.LoL now causes the following error:
> not.LoL[[1]]$start Error in not.LoL[[1]]$start : $ operator is invalid for atomic vectors
Concepts and / or solutions would be greatly appreciated.
Edit: I should have clearly indicated that the "id" is not actually unique here - there may be several elements under the same identifier. Therefore, I could do this with a solution that is independent of unique identifiers before split on.
MattLBeck
source share