I have a large data set and would like to find the row where multiple columns equal a specific value.
@Dij helped point me towards 'which' but unfortunately if I look for a row beyond row 9 of the data table, I receive an 'integer(0)' error
#Example##
Constants <- data.frame(Functional_Class_Code=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19),
F_Code=c(1,3,0,0,0,4,5,6,7,0,1,2,0,3,0,4,5,6,7),
Urban_Rural=c("R","R","0","0","0","R","R","R","R","0","U ","U ","0","U ","0","U ","U ","U ","U "),
g=c(0.0127,0.0202,0,0,0,0.0153,0.0156,0.0161,0.0185,0,0.0087,0.0129,0,0.0118,0,0.0112,0.0154,0.0154,0.0229))
##Example 1: find row 8 with the following DOES work...
UR = "R"
FC = 6
TheRow = which(Constants$Urban_Rural == UR & Constants$F_Code == FC)
TheRow
##Example 2: find row 14 with the following does NOT work...
UR = "U"
FC = 3
TheRow = which(Constants$Urban_Rural == UR & Constants$F_Code == FC)
TheRow
##error returned: integer(0)
Example 1 returns 8 correctly Example 2 should return 14 but does not