r – use dplyr to find a specific column matching the condition from another table

I have a criteria table:

    criteria <-data.frame(
        dx = c(0.244897959,
             6.112244898),
      slim_frac = c(0L, 1L),
           klim = c(1L, 40L),
     frackhfrac = c(0L, 1L),
            por = c(0.04, 0.16),
   matrix_k_log = c(-11L, -2L),
   srv_perm_log = c(-6L, 1L),
  frac_perm_log = c(-3L, 4L),
        pb_init = c(0L, 10000L),
            bhp = c(200L, 2000L)

I want to find all matching rows from my main table and extract the “srv_volumn” column, so dx needs to be within (0.244898, 6.112245) and slim_factor is (0,1) till bhp is within (200, 2000). Do I need to apply a map function to go through all rows of the criteria table?

Here’s part of my main database:

         main <- tibble::tribble(
  ~matrix_k, ~matrix_k_log, ~well_dd,   ~srv_perm, ~srv_perm_log, ~frac_perm, ~frac_perm_log,        ~por, ~inter_frac_spac, ~fracs_per_mile_well, ~models_per_7500_well, ~mod_radius,       ~dx, ~model_area, ~jlim, ~jlim2,  ~iws,  ~pb_init, ~klim, ~klim2, ~thickness, ~target_frac_len, ~flim, ~flength1, ~flength1_frac, ~flength2, ~flim2, ~eflim, ~eflim_1, ~eflim2, ~eflim2_2, ~frac_length_ratio, ~slim_frac, ~srv_width_along_well, ~slim, ~slim1_1, ~slim2, ~slim2_1, ~frackhfrac, ~f_height, ~fhlim, ~efhlim, ~efhlim2,    ~fh_fl, ~well_cell, ~int_well_spac_frac,  ~srv_area, ~srv_volume, ~rock_comp, ~srv_vol_frac,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,   1.2970541,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   98L,    258.72,           0.98,    258.72,    98L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 25842.279,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,   1.1791401,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   99L,     237.6,           0.99,     237.6,    99L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 23732.705,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,   1.0808784,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   99L,     217.8,           0.99,     217.8,    99L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 21754.979,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,  0.99773388,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   99L, 201.04615,           0.99, 201.04615,    99L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 20081.519,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,  0.92646719,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   99L, 186.68572,           0.99, 186.68572,    99L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 18647.126,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,  0.86470271,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   99L,    174.24,           0.99,    174.24,    99L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 17403.983,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
    7.8e-08,     -7.108125,    1000L, 0.026474569,    -1.5771711, 0.57349005,    -0.24147411,  0.11467016,        411.56523,            12.829072,             18.223114, 0.023894001, 4.1894411,  0.81065879,   52L,   101L, 166.4, 4869.1044,   23L,    24L,       115L,        256.57068,   99L,    163.35,           0.99,    163.35,    99L,    52L,      53L,     52L,       53L,                 1L, 0.42605267,             87.674232,   22L,      23L,    79L,      78L,  0.86856627, 99.885121,    20L,     20L,      21L, 16316.235,        11L,                   1,  2.7630667,   276.30667,      4e-06,    0.37387814,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   6.0353762,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   18L,     475.2,           0.18,     475.2,    18L,    18L,      19L,     18L,       19L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 36712.924,         9L,          0.34615385, 0.49134259,   39.307407,      4e-06,    0.11369702,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   3.0176881,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   36L,     475.2,           0.36,     475.2,    36L,    36L,      37L,     36L,       37L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 36712.924,         9L,          0.69230769, 0.98268517,   78.614814,      4e-06,    0.22739405,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   2.0117921,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   54L,     475.2,           0.54,     475.2,    54L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 36712.924,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   1.5088441,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   72L,     475.2,           0.72,     475.2,    72L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 36712.924,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   1.2070752,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   90L,     475.2,            0.9,     475.2,    90L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 36712.924,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,    1.005896,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,     435.6,           0.99,     435.6,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 33653.513,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.86219661,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L, 373.37143,           0.99, 373.37143,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 28845.869,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.75442203,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,     326.7,           0.99,     326.7,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 25240.135,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.67059735,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,     290.4,           0.99,     290.4,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 22435.676,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.60353762,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,    261.36,           0.99,    261.36,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 20192.108,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.54867057,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,     237.6,           0.99,     237.6,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 18356.462,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.50294802,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,     217.8,           0.99,     217.8,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 16826.757,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   0.4642597,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L, 201.04615,           0.99, 201.04615,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L,  15532.39,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,   0.4310983,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L, 186.68572,           0.99, 186.68572,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 14422.935,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.40235841,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,    174.24,           0.99,    174.24,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 13461.405,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   1.27e-09,    -8.8955454,    1000L, 0.004173795,    -2.3794689, 0.56748402,    -0.24604636,  0.11778517,        191.50713,            27.570775,             39.163033,  0.01629904, 1.9439503,  0.37721101,   52L,   101L, 166.4, 4305.5723,   23L,    24L,       115L,        469.93566,   99L,    163.35,           0.99,    163.35,    99L,    52L,      53L,     52L,       53L,                 1L, 0.47037139,             45.039737,   24L,      25L,    77L,      76L,  0.67180727, 77.257836,    16L,     16L,      17L, 12620.068,         9L,                   1,  1.4194341,   113.55473,      4e-06,    0.32845807,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   17.928434,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   14L,     369.6,           0.14,     369.6,    14L,    14L,      15L,     14L,       15L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3962.0403,         2L,          0.26923077,  2.2709871,   34.064807,      4e-06,    0.02347828,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,    8.964217,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   27L,     356.4,           0.27,     356.4,    27L,    27L,      28L,     27L,       28L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3820.5389,         2L,          0.51923077,  4.3797608,   65.696412,      4e-06,   0.045279539,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   5.9761446,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   41L,     360.8,           0.41,     360.8,    41L,    41L,      42L,     41L,       42L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L,  3867.706,         2L,          0.78846154,  6.6507479,   99.761219,      4e-06,   0.068757819,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   4.4821085,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   54L,     356.4,           0.54,     356.4,    54L,    52L,      53L,     52L,       53L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3820.5389,         2L,                   1,  8.4350949,   126.52642,      4e-06,   0.087205038,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   3.5856868,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   67L,    353.76,           0.67,    353.76,    67L,    52L,      53L,     52L,       53L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3792.2386,         2L,                   1,  8.4350949,   126.52642,      4e-06,   0.087205038,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   2.9880723,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   81L,     356.4,           0.81,     356.4,    81L,    52L,      53L,     52L,       53L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3820.5389,         2L,                   1,  8.4350949,   126.52642,      4e-06,   0.087205038,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   2.5612049,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   94L, 354.51429,           0.94, 354.51429,    94L,    52L,      53L,     52L,       53L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3800.3244,         2L,                   1,  8.4350949,   126.52642,      4e-06,   0.087205038,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   2.2410542,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   99L,     326.7,           0.99,     326.7,    99L,    52L,      53L,     52L,       53L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3502.1606,         2L,                   1,  8.4350949,   126.52642,      4e-06,   0.087205038,
   7.29e-05,     -4.136994,    1000L, 0.003622004,    -2.4410511,   47.36649,      1.6754712, 0.060275867,          568.883,            9.2813461,              13.18373, 0.028091894, 5.7947245,   1.9920482,   52L,   101L, 166.4, 4650.3077,   33L,    34L,       165L,        353.11059,   99L,     290.4,           0.99,     290.4,    99L,    52L,      53L,     52L,       53L,                 1L, 0.94097399,             267.65205,   48L,      49L,    53L,      52L, 0.064968519, 10.719806,     3L,      3L,       4L, 3113.0317,         2L,                   1,  8.4350949,   126.52642,      4e-06,   0.087205038
  )

Leave a Comment