I'm a beginner in R and I'm facing a rather simple issue. I need to create a list of a list iteratively with the data that is given below.
# First Vertical layer
P01<- list("S17","S18")
P02<- list("S1","S2")
P03<- list("S3","S4")
P1 <- list(P01, P02, P03)
# Second Vertical layer
P2 <- list("S22","S11","S12")
For each list in P1, I need to append it to the start of each value in P2 and record it in a list. What I need:
lt <- list(list("S17", "S18", "S22"),list("S17", "S18", "S11"),list("S17", "S18", "S12"), list("S1", "S2", "S22"), ....)
What I have written so far (but doesn't work):
for (val in P1){
for (lev in P2){
J <- append(val,lev)
}
}
I'm coming from a python background and this syntax and data type is becoming a bit problematic for me in R. Any help would be sufficient.