Displaying 1 result from an estimated 1 matches for "valuesofl3".
Did you mean:
valuesofl1
2010 Mar 24
1
flexible alternative to subsetting dataframe inside nested loops
I have a dataFrame variable:
L1 L2 L3 ... v1 v2 ...
1
2
3
4
...
I want to process subsets of it as defined by combinations of L1-L2-L3. I do
it successfully using nested loops:
for (i in valuesOfL1 {
for (j in valuesOfL2) {
for (k in valuesOfL3) {
tempData <- subset(dataFrame, (L1 == i & L2 == j & L3 == k,
select=c(v1,v2) ))
if (dim(tempData)[1]>0) # does this combination of L1-L2-L3 contain
any data?
{ process(tempData) }
}
}
}
It works fine but:
1. I'm sure there can be more efficient sol...