I have a dataframe like this:
row col
1 1
1 50
1 55
2 75
and I want to select all the row and col values that are paired so I can insert them into a function.
I am trying this code:
library(rhdf5)
for(row in df$row){
for (col in df$col){
apixel = h5read("C/path_to_a_file',, index=list(1, col, row))
apixel= data.frame(apixel)
}
}
This is inserting all my row
and col
values from my df like I want, but it is doing every possible combination of them I only want to insert the appropriate pairing. For instance, row
1 should only ever be paired with 1
, 50
and 55
as a corresponding col
, not 75
.
Possibly I could try to zip the two columns and then return the associated tuples?