问题
I have a data.table
(dt_1
) that contains measured values for 2 columns (Observed_A
and Observed_B
). I need to use the values from those columns and lookup the nearest values to both columns in a second lookup styled data.table
(dt_2
) referencing columns Modeled_A
and Modeled_B
, respectively. The ultimate goal is to then, using the rows that have the nearest matches in dt_2
, select the 3 additional modeled column values in dt_2
(Variable_1
, Variable_2
and Variable_3
) and add them into dt_1
.
I'm hoping to use data.table
's roll
function as my actual data.tables
are large (dt_1
; 30 columns and 35000 rows) (dt_2
; 17 columns and 15,000 rows) but I'm not sure how to accomplish this with 2 columns simultaneously.
Here's some example data:
dt_1 <- structure(list(Observed_A = c(-9.7, -10.8, -9.7, -9.2, -9.5,
-10.1, -8.3, -7.6), Observed_B = c(-3.1, -5.2, -4.5, -4.1, -3,
-2.7, -2.6, -2.6)), class = "data.frame", row.names = c(NA, -8L))
dt_2 <- structure(list(Modeled_A = c(-6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5,
-6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -6.5, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2,
-8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -8.2, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8, -9.8,
-9.8, -9.8, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4, -11.4,
-11.4, -11.4), Modeled_B = c(-5.9, -5.9, -5.9, -5.9, -5.9, -5.9,
-5.9, -5.9, -5.9, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3,
-4.3, -4.3, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8,
-2.8, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2,
0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 1.9, 1.9, 1.9,
1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4,
3.4, 3.4, 3.4, 3.4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -40, -40, -40,
-40, -40, -40, -40, -40, -40, -40, -38.4, -38.4, -38.4, -38.4,
-38.4, -38.4, -38.4, -38.4, -38.4, -38.4, -36.9, -36.9, -36.9,
-36.9, -36.9, -36.9, -36.9, -36.9, -36.9, -36.9, -35.3, -35.3,
-35.3, -35.3, -35.3, -35.3, -35.3, -35.3, -35.3, -35.3, -33.8,
-33.8, -33.8, -33.8, -33.8, -33.8, -33.8, -33.8, -33.8, -33.8,
-32.2, -32.2, -32.2, -32.2, -32.2, -32.2, -32.2, -32.2, -32.2,
-32.2, -30.7, -30.7, -30.7, -30.7, -30.7, -30.7, -30.7, -30.7,
-30.7, -30.7, -29.1, -29.1, -29.1, -29.1, -29.1, -29.1, -29.1,
-29.1, -29.1, -29.1, -27.6, -27.6, -27.6, -27.6, -27.6, -27.6,
-27.6, -27.6, -27.6, -27.6, -26, -26, -26, -26, -26, -26, -26,
-26, -26, -26, -24.5, -24.5, -24.5, -24.5, -24.5, -24.5, -24.5,
-24.5, -24.5, -24.5, -22.9, -22.9, -22.9, -22.9, -22.9, -22.9,
-22.9, -22.9, -22.9, -22.9, -21.4, -21.4, -21.4, -21.4, -21.4,
-21.4, -21.4, -21.4, -21.4, -21.4, -19.8, -19.8, -19.8, -19.8,
-19.8, -19.8, -19.8, -19.8, -19.8, -19.8, -18.3, -18.3, -18.3,
-18.3, -18.3, -18.3, -18.3, -18.3, -18.3, -18.3, -16.7, -16.7,
-16.7, -16.7, -16.7, -16.7, -16.7, -16.7, -16.7, -16.7, -15.2,
-15.2, -15.2, -15.2, -15.2, -15.2, -15.2, -15.2, -15.2, -15.2,
-13.6, -13.6, -13.6, -13.6, -13.6, -13.6, -13.6, -13.6, -13.6,
-13.6, -12.1, -12.1, -12.1, -12.1, -12.1, -12.1, -12.1, -12.1,
-12.1, -12.1, -10.5, -10.5, -10.5, -10.5, -10.5, -10.5, -10.5,
-10.5, -10.5, -10.5, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -5.9,
-5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -4.3, -4.3,
-4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -2.8, -2.8, -2.8,
-2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -1.2, -1.2, -1.2, -1.2,
-1.2, -1.2, -1.2, -1.2, -1.2, -1.2, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9,
1.9, 1.9, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, -40, -40, -40, -40, -40, -40, -40,
-40, -40, -40, -38.4, -38.4, -38.4, -38.4, -38.4, -38.4, -38.4,
-38.4, -38.4, -38.4, -36.9, -36.9, -36.9, -36.9, -36.9, -36.9,
-36.9, -36.9, -36.9, -36.9, -35.3, -35.3, -35.3, -35.3, -35.3,
-35.3, -35.3, -35.3, -35.3, -35.3, -33.8, -33.8, -33.8, -33.8,
-33.8, -33.8, -33.8, -33.8, -33.8, -33.8, -32.2, -32.2, -32.2,
-32.2, -32.2, -32.2, -32.2, -32.2, -32.2, -32.2, -30.7, -30.7,
-30.7, -30.7, -30.7, -30.7, -30.7, -30.7, -30.7, -30.7, -29.1,
-29.1, -29.1, -29.1, -29.1, -29.1, -29.1, -29.1, -29.1, -29.1,
-27.6, -27.6, -27.6, -27.6, -27.6, -27.6, -27.6, -27.6, -27.6,
-27.6, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -24.5,
-24.5, -24.5, -24.5, -24.5, -24.5, -24.5, -24.5, -24.5, -24.5,
-22.9, -22.9, -22.9, -22.9, -22.9, -22.9, -22.9, -22.9, -22.9,
-22.9, -21.4, -21.4, -21.4, -21.4, -21.4, -21.4, -21.4, -21.4,
-21.4, -21.4, -19.8, -19.8, -19.8, -19.8, -19.8, -19.8, -19.8,
-19.8, -19.8, -19.8, -18.3, -18.3, -18.3, -18.3, -18.3, -18.3,
-18.3, -18.3, -18.3, -18.3, -16.7, -16.7, -16.7, -16.7, -16.7,
-16.7, -16.7, -16.7, -16.7, -16.7, -15.2, -15.2, -15.2, -15.2,
-15.2, -15.2, -15.2, -15.2, -15.2, -15.2, -13.6, -13.6, -13.6,
-13.6, -13.6, -13.6, -13.6, -13.6, -13.6, -13.6, -12.1, -12.1,
-12.1, -12.1, -12.1, -12.1, -12.1, -12.1, -12.1, -12.1, -10.5,
-10.5, -10.5, -10.5, -10.5, -10.5, -10.5, -10.5, -10.5, -10.5,
-9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -7.4, -7.4, -7.4, -7.4,
-7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -5.9, -5.9, -5.9, -5.9, -5.9,
-5.9, -5.9, -5.9, -5.9, -5.9, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3,
-4.3, -4.3, -4.3, -4.3, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8,
-2.8, -2.8, -2.8, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2,
-1.2, -1.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 1.9, 3.4, 3.4, 3.4,
3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -38.4, -38.4,
-38.4, -38.4, -38.4, -38.4, -38.4, -38.4, -38.4, -38.4, -36.9,
-36.9, -36.9, -36.9, -36.9, -36.9, -36.9, -36.9, -36.9, -36.9,
-35.3, -35.3, -35.3, -35.3, -35.3, -35.3, -35.3, -35.3, -35.3,
-35.3, -33.8, -33.8, -33.8, -33.8, -33.8, -33.8, -33.8, -33.8,
-33.8, -33.8, -32.2, -32.2, -32.2, -32.2, -32.2, -32.2, -32.2,
-32.2, -32.2, -32.2, -30.7, -30.7, -30.7, -30.7, -30.7, -30.7,
-30.7, -30.7, -30.7, -30.7, -29.1, -29.1, -29.1, -29.1, -29.1,
-29.1, -29.1, -29.1, -29.1, -29.1, -27.6, -27.6, -27.6, -27.6,
-27.6, -27.6, -27.6, -27.6, -27.6, -27.6, -26, -26, -26, -26,
-26, -26, -26, -26, -26, -26, -24.5, -24.5, -24.5, -24.5, -24.5,
-24.5, -24.5, -24.5, -24.5, -24.5, -22.9, -22.9, -22.9, -22.9,
-22.9, -22.9, -22.9, -22.9, -22.9, -22.9, -21.4, -21.4, -21.4,
-21.4, -21.4, -21.4, -21.4, -21.4, -21.4, -21.4, -19.8, -19.8,
-19.8, -19.8, -19.8, -19.8, -19.8, -19.8, -19.8, -19.8, -18.3,
-18.3, -18.3, -18.3, -18.3, -18.3, -18.3, -18.3, -18.3, -18.3,
-16.7, -16.7, -16.7, -16.7, -16.7, -16.7, -16.7, -16.7, -16.7,
-16.7, -15.2, -15.2, -15.2, -15.2, -15.2, -15.2, -15.2, -15.2,
-15.2, -15.2, -13.6, -13.6, -13.6, -13.6, -13.6, -13.6, -13.6,
-13.6, -13.6, -13.6, -12.1, -12.1, -12.1, -12.1, -12.1, -12.1,
-12.1, -12.1, -12.1, -12.1, -10.5, -10.5, -10.5, -10.5, -10.5,
-10.5, -10.5, -10.5, -10.5, -10.5, -9, -9, -9, -9, -9, -9, -9,
-9, -9, -9, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4, -7.4,
-7.4, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9, -5.9,
-4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -2.8,
-2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -2.8, -1.2, -1.2,
-1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, -1.2, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3), Variable_1 = c(29L, 79L,
41L, 89L, 94L, 4L, 53L, 90L, 55L, 46L, 96L, 45L, 68L, 57L, 10L,
90L, 24L, 4L, 33L, 96L, 89L, 69L, 64L, 100L, 66L, 71L, 54L, 60L,
29L, 14L, 97L, 91L, 69L, 80L, 2L, 48L, 76L, 21L, 32L, 23L, 14L,
41L, 41L, 37L, 15L, 14L, 23L, 47L, 26L, 86L, 4L, 44L, 80L, 12L,
56L, 20L, 12L, 76L, 90L, 37L, 67L, 9L, 38L, 27L, 82L, 45L, 81L,
82L, 80L, 44L, 76L, 63L, 71L, 0L, 48L, 22L, 38L, 61L, 35L, 11L,
24L, 67L, 42L, 79L, 10L, 43L, 99L, 90L, 89L, 17L, 13L, 65L, 34L,
66L, 32L, 18L, 79L, 9L, 47L, 51L, 60L, 33L, 49L, 96L, 48L, 89L,
92L, 61L, 41L, 14L, 94L, 30L, 6L, 95L, 72L, 14L, 55L, 96L, 59L,
40L, 65L, 32L, 31L, 22L, 37L, 99L, 15L, 9L, 14L, 69L, 62L, 90L,
67L, 74L, 52L, 66L, 83L, 79L, 98L, 44L, 31L, 41L, 1L, 18L, 85L,
23L, 24L, 7L, 24L, 73L, 85L, 50L, 39L, 24L, 11L, 39L, 57L, 21L,
44L, 22L, 50L, 35L, 65L, 37L, 35L, 53L, 74L, 22L, 41L, 26L, 63L,
18L, 87L, 75L, 67L, 62L, 37L, 53L, 88L, 58L, 84L, 31L, 71L, 26L,
60L, 48L, 26L, 57L, 92L, 91L, 27L, 32L, 99L, 62L, 94L, 47L, 41L,
66L, 15L, 57L, 24L, 97L, 60L, 52L, 40L, 88L, 36L, 29L, 17L, 17L,
48L, 25L, 21L, 68L, 4L, 70L, 35L, 41L, 82L, 92L, 28L, 97L, 73L,
69L, 5L, 39L, 48L, 56L, 70L, 92L, 62L, 43L, 54L, 5L, 26L, 40L,
19L, 84L, 15L, 81L, 55L, 66L, 17L, 63L, 31L, 73L, 40L, 97L, 97L,
73L, 25L, 22L, 59L, 27L, 53L, 79L, 16L, 40L, 47L, 87L, 93L, 89L,
68L, 95L, 52L, 58L, 33L, 35L, 2L, 50L, 87L, 0L, 7L, 16L, 77L,
74L, 98L, 47L, 7L, 65L, 76L, 13L, 40L, 22L, 5L, 39L, 6L, 22L,
5L, 67L, 30L, 10L, 7L, 88L, 76L, 82L, 99L, 10L, 10L, 80L, 79L,
0L, 78L, 73L, 63L, 48L, 15L, 0L, 45L, 49L, 39L, 46L, 72L, 5L,
35L, 81L, 84L, 24L, 35L, 86L, 86L, 29L, 14L, 71L, 10L, 3L, 100L,
3L, 34L, 92L, 62L, 28L, 74L, 84L, 31L, 49L, 70L, 64L, 65L, 98L,
41L, 12L, 53L, 22L, 49L, 37L, 99L, 39L, 23L, 62L, 13L, 97L, 52L,
16L, 62L, 99L, 67L, 42L, 32L, 84L, 14L, 19L, 90L, 31L, 36L, 79L,
19L, 1L, 41L, 48L, 42L, 34L, 87L, 45L, 53L, 97L, 78L, 21L, 31L,
98L, 59L, 76L, 37L, 77L, 54L, 92L, 18L, 28L, 9L, 21L, 98L, 29L,
73L, 79L, 10L, 24L, 27L, 10L, 11L, 100L, 99L, 13L, 91L, 58L,
39L, 45L, 71L, 8L, 34L, 68L, 32L, 83L, 21L, 50L, 27L, 19L, 96L,
32L, 48L, 2L, 55L, 65L, 60L, 32L, 90L, 63L, 30L, 39L, 16L, 87L,
96L, 56L, 33L, 100L, 23L, 61L, 10L, 49L, 10L, 16L, 28L, 58L,
73L, 16L, 87L, 71L, 76L, 14L, 36L, 68L, 52L, 35L, 24L, 5L, 23L,
89L, 81L, 75L, 15L, 12L, 98L, 44L, 46L, 16L, 59L, 27L, 23L, 69L,
28L, 81L, 9L, 83L, 43L, 76L, 66L, 44L, 63L, 0L, 21L, 71L, 21L,
82L, 31L, 69L, 94L, 11L, 12L, 68L, 43L, 84L, 98L, 7L, 46L, 70L,
8L, 100L, 25L, 5L, 69L, 79L, 35L, 37L, 28L, 8L, 36L, 17L, 54L,
50L, 95L, 34L, 46L, 8L, 86L, 39L, 74L, 17L, 45L, 77L, 6L, 82L,
30L, 36L, 31L, 3L, 52L, 68L, 91L, 2L, 99L, 30L, 94L, 69L, 45L,
82L, 3L, 74L, 35L, 83L, 54L, 27L, 80L, 9L, 84L, 27L, 76L, 97L,
8L, 86L, 81L, 38L, 33L, 20L, 57L, 89L, 53L, 59L, 67L, 53L, 51L,
1L, 4L, 93L, 77L, 20L, 65L, 66L, 39L, 82L, 55L, 89L, 55L, 91L,
59L, 42L, 95L, 71L, 41L, 1L, 57L, 49L, 88L, 82L, 86L, 37L, 88L,
15L, 28L, 67L, 98L, 58L, 53L, 6L, 97L, 12L, 8L, 88L, 51L, 34L,
90L, 3L, 23L, 69L, 22L, 32L, 17L, 80L, 14L, 83L, 33L, 37L, 63L,
9L, 2L, 100L, 58L, 78L, 90L, 76L, 98L, 4L, 91L, 87L, 78L, 38L,
4L, 36L, 27L, 85L, 36L, 30L, 76L, 85L, 46L, 73L, 10L, 22L, 96L,
75L, 82L, 42L, 59L, 80L, 89L, 38L, 9L, 63L, 75L, 8L, 30L, 62L,
76L, 92L, 48L, 57L, 74L, 86L, 91L, 5L, 50L, 35L, 85L, 81L, 11L,
71L, 23L, 7L, 94L, 15L, 65L, 17L, 2L, 52L, 8L, 28L, 42L, 59L,
81L, 20L, 46L, 45L, 74L, 72L, 83L, 89L, 96L, 55L, 52L, 17L, 48L,
25L, 4L, 64L, 54L, 14L, 28L, 58L, 16L, 9L, 43L, 35L, 85L, 26L,
2L, 87L, 33L, 63L, 55L, 38L, 18L, 43L, 63L, 52L, 66L, 73L, 49L,
38L, 0L, 0L, 100L, 10L, 42L, 72L, 74L, 88L, 61L, 76L, 85L, 61L,
80L, 2L, 42L, 88L, 65L, 93L, 17L, 31L, 81L, 99L, 32L, 0L, 100L,
14L, 4L, 60L, 32L, 53L, 80L, 6L, 70L, 95L, 28L, 25L, 16L, 7L,
56L, 49L, 49L, 89L, 3L, 20L, 51L, 23L, 58L, 48L, 57L, 14L, 14L,
41L, 68L, 65L, 92L, 82L, 68L, 81L, 12L, 25L, 33L, 41L, 64L, 81L,
26L, 82L, 1L, 66L, 81L, 46L, 20L, 1L, 28L, 92L, 94L, 54L, 22L,
49L, 80L, 41L, 10L, 28L, 36L, 26L, 47L, 36L, 12L, 4L, 26L, 97L,
49L, 48L, 75L, 67L, 4L, 70L, 36L, 89L, 78L, 14L, 29L, 12L, 59L,
56L, 69L, 31L, 61L, 100L, 75L, 7L, 45L, 5L, 34L, 74L, 0L, 77L,
46L, 72L, 67L, 57L, 71L, 66L, 29L, 9L, 97L, 74L, 61L, 12L, 55L,
26L, 90L, 0L, 23L, 13L, 32L, 73L, 100L, 72L, 50L, 44L, 95L, 12L,
7L, 89L, 42L, 4L, 65L, 47L, 62L, 27L, 15L, 11L, 51L, 55L, 14L,
17L, 76L, 53L, 86L, 68L, 1L, 70L, 90L, 63L, 10L, 93L, 68L, 15L,
75L, 95L, 42L, 30L, 26L, 22L, 57L, 76L, 67L, 55L, 81L, 76L, 2L,
38L, 5L, 80L, 93L, 54L, 86L, 58L, 67L, 51L, 77L, 91L, 82L, 7L,
0L, 5L, 87L, 58L, 31L, 96L, 59L, 53L, 38L, 32L, 81L, 4L, 36L,
86L, 70L, 69L, 35L, 56L, 13L, 79L, 89L, 20L, 77L, 60L, 96L, 16L,
53L, 88L, 87L, 2L, 98L, 49L, 39L, 42L, 9L, 16L, 40L, 34L, 41L
), Variable_2 = c(180L, 289L, 760L, 867L, 810L, 399L, 174L, 357L,
313L, 447L, 436L, 296L, 780L, 840L, 639L, 686L, 859L, 508L, 745L,
362L, 262L, 750L, 915L, 501L, 855L, 733L, 956L, 679L, 167L, 328L,
977L, 295L, 963L, 552L, 686L, 954L, 990L, 927L, 945L, 576L, 386L,
481L, 138L, 216L, 169L, 170L, 624L, 590L, 537L, 936L, 885L, 819L,
389L, 483L, 434L, 905L, 938L, 656L, 224L, 328L, 368L, 468L, 348L,
664L, 120L, 396L, 655L, 477L, 611L, 578L, 969L, 863L, 329L, 168L,
500L, 101L, 402L, 436L, 536L, 643L, 540L, 594L, 688L, 947L, 461L,
840L, 580L, 497L, 984L, 853L, 593L, 819L, 592L, 994L, 802L, 813L,
208L, 451L, 693L, 736L, 327L, 220L, 459L, 354L, 776L, 826L, 834L,
730L, 759L, 389L, 791L, 348L, 406L, 716L, 947L, 948L, 736L, 857L,
746L, 779L, 110L, 147L, 246L, 721L, 478L, 817L, 834L, 559L, 534L,
169L, 956L, 403L, 947L, 745L, 168L, 723L, 364L, 954L, 298L, 965L,
489L, 311L, 535L, 488L, 138L, 620L, 934L, 992L, 543L, 897L, 646L,
943L, 509L, 216L, 276L, 988L, 235L, 722L, 629L, 625L, 226L, 698L,
396L, 587L, 981L, 172L, 576L, 458L, 785L, 984L, 823L, 611L, 161L,
269L, 840L, 546L, 603L, 762L, 466L, 936L, 386L, 875L, 326L, 192L,
922L, 816L, 929L, 707L, 308L, 259L, 521L, 368L, 812L, 461L, 723L,
155L, 883L, 885L, 489L, 612L, 592L, 712L, 827L, 158L, 517L, 261L,
575L, 640L, 141L, 333L, 882L, 239L, 179L, 797L, 366L, 301L, 420L,
192L, 675L, 151L, 288L, 690L, 486L, 388L, 213L, 263L, 585L, 205L,
813L, 331L, 854L, 268L, 823L, 990L, 898L, 926L, 168L, 872L, 222L,
555L, 452L, 412L, 334L, 674L, 824L, 989L, 661L, 848L, 901L, 401L,
217L, 451L, 634L, 647L, 191L, 446L, 662L, 131L, 675L, 314L, 551L,
693L, 888L, 103L, 379L, 876L, 305L, 971L, 189L, 104L, 236L, 657L,
117L, 107L, 401L, 212L, 296L, 335L, 485L, 721L, 275L, 613L, 485L,
584L, 924L, 355L, 920L, 293L, 212L, 550L, 796L, 585L, 943L, 682L,
165L, 746L, 899L, 341L, 263L, 861L, 897L, 169L, 491L, 701L, 379L,
662L, 153L, 190L, 425L, 913L, 238L, 911L, 895L, 722L, 632L, 393L,
191L, 496L, 780L, 885L, 540L, 167L, 221L, 760L, 235L, 158L, 600L,
595L, 778L, 169L, 215L, 217L, 966L, 989L, 516L, 402L, 109L, 742L,
604L, 269L, 320L, 240L, 817L, 733L, 896L, 240L, 660L, 458L, 154L,
669L, 434L, 896L, 171L, 705L, 243L, 872L, 109L, 717L, 844L, 381L,
174L, 241L, 343L, 633L, 663L, 843L, 466L, 188L, 873L, 499L, 514L,
438L, 872L, 484L, 865L, 784L, 443L, 583L, 857L, 873L, 318L, 906L,
838L, 554L, 902L, 741L, 791L, 591L, 389L, 120L, 904L, 109L, 480L,
834L, 229L, 629L, 646L, 137L, 384L, 365L, 654L, 433L, 869L, 528L,
548L, 387L, 408L, 956L, 521L, 149L, 227L, 784L, 356L, 553L, 596L,
822L, 584L, 336L, 771L, 491L, 895L, 381L, 772L, 936L, 782L, 215L,
362L, 132L, 552L, 692L, 925L, 351L, 845L, 420L, 711L, 783L, 594L,
305L, 818L, 112L, 137L, 774L, 927L, 395L, 401L, 259L, 258L, 745L,
372L, 949L, 753L, 494L, 732L, 576L, 161L, 960L, 922L, 886L, 774L,
834L, 957L, 854L, 323L, 124L, 832L, 291L, 579L, 470L, 487L, 100L,
770L, 343L, 302L, 522L, 759L, 981L, 983L, 856L, 213L, 828L, 972L,
759L, 276L, 711L, 230L, 451L, 803L, 844L, 277L, 117L, 129L, 470L,
859L, 654L, 697L, 458L, 237L, 230L, 779L, 139L, 461L, 281L, 576L,
737L, 639L, 923L, 198L, 244L, 529L, 161L, 422L, 324L, 189L, 500L,
473L, 363L, 396L, 396L, 675L, 198L, 875L, 444L, 358L, 695L, 700L,
975L, 959L, 111L, 834L, 788L, 514L, 644L, 245L, 377L, 960L, 232L,
640L, 394L, 815L, 779L, 107L, 909L, 604L, 662L, 125L, 902L, 956L,
793L, 722L, 996L, 510L, 946L, 822L, 305L, 538L, 692L, 214L, 964L,
557L, 571L, 823L, 754L, 553L, 494L, 965L, 358L, 590L, 317L, 997L,
422L, 353L, 483L, 311L, 183L, 524L, 711L, 240L, 959L, 322L, 810L,
252L, 836L, 772L, 859L, 816L, 858L, 611L, 893L, 293L, 654L, 670L,
827L, 525L, 193L, 281L, 219L, 423L, 958L, 904L, 251L, 216L, 925L,
689L, 975L, 322L, 843L, 985L, 480L, 449L, 857L, 637L, 964L, 225L,
930L, 182L, 380L, 913L, 857L, 486L, 448L, 461L, 517L, 826L, 958L,
598L, 889L, 706L, 819L, 715L, 931L, 682L, 689L, 847L, 293L, 599L,
817L, 795L, 444L, 968L, 570L, 532L, 796L, 432L, 293L, 760L, 941L,
460L, 368L, 913L, 638L, 605L, 617L, 308L, 913L, 581L, 921L, 740L,
130L, 661L, 240L, 881L, 803L, 451L, 463L, 893L, 300L, 308L, 895L,
986L, 744L, 262L, 639L, 981L, 181L, 670L, 212L, 207L, 994L, 437L,
617L, 513L, 397L, 415L, 529L, 336L, 991L, 933L, 767L, 167L, 664L,
488L, 230L, 597L, 128L, 291L, 650L, 654L, 454L, 605L, 762L, 952L,
118L, 587L, 686L, 386L, 844L, 922L, 849L, 936L, 188L, 691L, 621L,
783L, 927L, 834L, 395L, 818L, 428L, 674L, 181L, 813L, 665L, 839L,
672L, 326L, 876L, 815L, 225L, 794L, 888L, 281L, 198L, 556L, 920L,
348L, 249L, 331L, 975L, 206L, 669L, 645L, 174L, 136L, 400L, 804L,
534L, 980L, 449L, 490L, 531L, 482L, 224L, 867L, 356L, 381L, 879L,
638L, 906L, 721L, 161L, 192L, 920L, 952L, 577L, 436L, 148L, 182L,
720L, 660L, 604L, 451L, 728L, 844L, 385L, 764L, 598L, 500L, 600L,
234L, 768L, 243L, 650L, 287L, 550L, 698L, 270L, 203L, 108L, 942L,
897L, 541L, 383L, 272L, 725L, 724L, 640L, 566L, 187L, 153L, 723L,
787L, 868L, 404L, 464L, 539L, 167L, 264L, 265L, 550L, 825L, 927L,
285L, 814L, 163L, 865L, 614L, 955L, 601L, 845L, 231L, 167L, 198L,
960L, 334L, 958L, 630L, 462L, 661L, 995L, 445L, 631L, 143L, 695L,
969L, 111L, 848L, 252L, 266L, 322L, 201L, 404L, 723L, 336L, 833L,
579L, 392L, 452L, 652L, 836L, 458L, 600L, 715L, 311L, 473L, 681L,
589L, 806L, 214L, 237L, 653L, 706L, 595L, 899L, 194L, 861L, 296L,
937L, 131L, 830L, 162L, 731L, 263L, 490L, 172L, 575L, 373L, 554L,
779L, 547L, 515L, 973L, 607L, 746L, 433L, 690L, 615L, 388L, 970L,
595L, 311L, 921L, 826L, 934L, 949L, 586L, 923L, 427L, 394L, 859L,
865L, 347L, 279L, 868L, 642L, 632L, 850L, 287L, 123L, 496L, 665L,
707L, 662L, 719L, 856L, 504L, 129L, 736L, 130L, 580L, 600L, 827L,
522L, 999L, 437L, 917L, 420L, 322L, 727L, 332L, 438L, 491L, 798L,
830L, 156L, 995L, 978L, 991L, 826L, 173L, 329L, 208L, 852L, 658L,
841L, 228L, 758L, 519L, 394L, 731L), Variable_3 = c(225L, 73L,
52L, 198L, 173L, 55L, 193L, 91L, 140L, 136L, 128L, 177L, 113L,
166L, 158L, 54L, 89L, 211L, 243L, 77L, 136L, 162L, 89L, 126L,
157L, 179L, 128L, 174L, 256L, 176L, 105L, 119L, 216L, 172L, 118L,
159L, 196L, 120L, 104L, 236L, 110L, 247L, 238L, 300L, 99L, 91L,
211L, 281L, 69L, 237L, 126L, 59L, 148L, 283L, 155L, 280L, 251L,
187L, 158L, 124L, 138L, 226L, 82L, 217L, 232L, 238L, 229L, 241L,
107L, 122L, 86L, 244L, 73L, 95L, 155L, 150L, 118L, 177L, 237L,
272L, 159L, 195L, 291L, 253L, 287L, 132L, 248L, 258L, 275L, 70L,
224L, 78L, 50L, 55L, 221L, 115L, 234L, 192L, 260L, 118L, 170L,
128L, 66L, 273L, 247L, 91L, 161L, 157L, 110L, 170L, 233L, 207L,
266L, 158L, 109L, 79L, 269L, 144L, 273L, 212L, 143L, 297L, 242L,
228L, 147L, 259L, 298L, 241L, 209L, 91L, 141L, 207L, 96L, 111L,
137L, 246L, 92L, 231L, 245L, 65L, 227L, 194L, 264L, 192L, 271L,
144L, 142L, 57L, 86L, 68L, 149L, 234L, 284L, 165L, 246L, 58L,
208L, 107L, 63L, 198L, 292L, 240L, 221L, 184L, 90L, 207L, 200L,
81L, 69L, 172L, 184L, 237L, 206L, 210L, 132L, 247L, 68L, 123L,
277L, 234L, 129L, 216L, 264L, 264L, 101L, 114L, 82L, 74L, 51L,
247L, 260L, 113L, 195L, 186L, 116L, 95L, 219L, 148L, 284L, 122L,
123L, 73L, 136L, 104L, 230L, 282L, 191L, 258L, 189L, 78L, 229L,
284L, 240L, 228L, 85L, 84L, 239L, 142L, 157L, 197L, 199L, 53L,
56L, 196L, 50L, 248L, 241L, 257L, 141L, 214L, 252L, 159L, 213L,
123L, 103L, 181L, 209L, 109L, 280L, 256L, 102L, 176L, 211L, 170L,
215L, 268L, 258L, 250L, 155L, 156L, 229L, 265L, 217L, 200L, 176L,
292L, 163L, 267L, 204L, 120L, 74L, 218L, 224L, 141L, 65L, 261L,
197L, 104L, 177L, 56L, 55L, 274L, 109L, 62L, 229L, 225L, 169L,
264L, 300L, 58L, 82L, 283L, 58L, 281L, 163L, 265L, 231L, 109L,
149L, 172L, 102L, 295L, 224L, 138L, 271L, 128L, 292L, 224L, 113L,
287L, 122L, 242L, 129L, 156L, 194L, 244L, 280L, 231L, 105L, 121L,
190L, 118L, 136L, 247L, 113L, 196L, 167L, 240L, 241L, 246L, 266L,
54L, 137L, 279L, 103L, 125L, 173L, 99L, 268L, 280L, 70L, 81L,
62L, 218L, 112L, 146L, 285L, 130L, 179L, 101L, 69L, 278L, 128L,
94L, 186L, 132L, 295L, 118L, 274L, 262L, 100L, 218L, 199L, 292L,
53L, 208L, 57L, 260L, 225L, 95L, 289L, 243L, 168L, 268L, 239L,
134L, 66L, 286L, 220L, 268L, 285L, 185L, 173L, 296L, 117L, 272L,
173L, 257L, 147L, 282L, 91L, 96L, 95L, 291L, 68L, 238L, 288L,
264L, 263L, 294L, 262L, 71L, 92L, 68L, 169L, 273L, 53L, 121L,
142L, 71L, 50L, 185L, 62L, 131L, 80L, 277L, 295L, 279L, 133L,
248L, 102L, 279L, 164L, 142L, 258L, 141L, 62L, 242L, 198L, 292L,
154L, 189L, 177L, 239L, 252L, 235L, 160L, 136L, 154L, 161L, 249L,
214L, 261L, 148L, 63L, 81L, 149L, 276L, 181L, 173L, 123L, 199L,
263L, 132L, 105L, 151L, 63L, 61L, 136L, 172L, 222L, 237L, 62L,
256L, 277L, 295L, 125L, 258L, 187L, 132L, 177L, 108L, 278L, 72L,
112L, 176L, 268L, 229L, 122L, 85L, 202L, 208L, 249L, 83L, 234L,
286L, 115L, 222L, 78L, 295L, 64L, 284L, 224L, 90L, 141L, 119L,
105L, 80L, 194L, 146L, 280L, 155L, 249L, 132L, 202L, 145L, 158L,
90L, 254L, 157L, 117L, 169L, 190L, 258L, 173L, 140L, 77L, 276L,
66L, 60L, 246L, 110L, 88L, 90L, 104L, 284L, 202L, 157L, 67L,
156L, 53L, 148L, 227L, 287L, 184L, 225L, 129L, 77L, 107L, 116L,
224L, 265L, 72L, 142L, 222L, 110L, 207L, 220L, 169L, 267L, 235L,
292L, 199L, 229L, 126L, 177L, 220L, 191L, 63L, 250L, 158L, 80L,
239L, 74L, 59L, 275L, 263L, 65L, 295L, 298L, 232L, 164L, 224L,
167L, 56L, 260L, 225L, 268L, 164L, 95L, 248L, 127L, 139L, 270L,
179L, 125L, 177L, 97L, 211L, 150L, 97L, 58L, 267L, 158L, 179L,
235L, 257L, 292L, 196L, 225L, 288L, 54L, 82L, 231L, 97L, 133L,
264L, 184L, 265L, 230L, 85L, 296L, 95L, 280L, 269L, 281L, 99L,
224L, 211L, 281L, 63L, 76L, 258L, 254L, 182L, 107L, 64L, 79L,
79L, 251L, 184L, 142L, 173L, 233L, 123L, 100L, 246L, 259L, 66L,
165L, 174L, 269L, 248L, 237L, 155L, 150L, 263L, 141L, 82L, 253L,
101L, 292L, 299L, 300L, 162L, 133L, 297L, 112L, 262L, 137L, 235L,
89L, 110L, 186L, 197L, 150L, 298L, 97L, 188L, 257L, 225L, 160L,
59L, 85L, 223L, 181L, 58L, 114L, 65L, 65L, 192L, 56L, 105L, 110L,
268L, 269L, 209L, 118L, 258L, 110L, 264L, 119L, 285L, 173L, 283L,
153L, 234L, 55L, 169L, 116L, 265L, 117L, 276L, 267L, 172L, 180L,
194L, 135L, 115L, 283L, 142L, 53L, 290L, 214L, 208L, 71L, 200L,
216L, 209L, 67L, 268L, 124L, 59L, 89L, 290L, 68L, 108L, 250L,
259L, 70L, 171L, 65L, 102L, 173L, 132L, 61L, 147L, 175L, 160L,
152L, 246L, 62L, 209L, 92L, 94L, 54L, 187L, 131L, 146L, 275L,
278L, 86L, 236L, 97L, 134L, 126L, 165L, 63L, 274L, 74L, 280L,
197L, 129L, 148L, 277L, 81L, 107L, 155L, 50L, 196L, 103L, 83L,
218L, 232L, 64L, 55L, 71L, 118L, 185L, 266L, 228L, 247L, 243L,
262L, 246L, 197L, 289L, 298L, 213L, 247L, 170L, 245L, 258L, 99L,
150L, 93L, 223L, 247L, 156L, 269L, 255L, 175L, 213L, 150L, 135L,
56L, 292L, 60L, 62L, 73L, 264L, 63L, 219L, 164L, 126L, 128L,
95L, 57L, 291L, 63L, 159L, 118L, 149L, 125L, 74L, 129L, 172L,
139L, 130L, 136L, 294L, 218L, 226L, 269L, 53L, 77L, 140L, 59L,
69L, 195L, 75L, 200L, 219L, 235L, 124L, 277L, 71L, 65L, 147L,
261L, 198L, 172L, 147L, 110L, 114L, 268L, 225L, 260L, 98L, 242L,
203L, 147L, 283L, 145L, 215L, 124L, 144L, 244L, 183L, 274L, 281L,
122L, 258L, 55L, 280L, 151L, 116L, 222L, 146L, 124L, 277L, 247L,
195L, 294L, 233L, 194L, 247L, 278L, 134L, 188L, 192L, 255L, 188L,
188L, 162L, 150L, 252L, 223L, 293L, 191L, 164L, 84L, 256L, 292L,
269L, 248L, 256L, 294L, 298L, 63L, 117L, 225L, 100L, 243L, 196L,
165L, 237L, 275L, 286L, 215L, 183L, 144L, 77L, 144L, 155L, 236L,
195L, 216L, 274L, 296L, 123L, 139L, 126L, 297L, 62L, 134L, 90L,
102L, 278L, 219L, 78L, 185L, 165L, 275L, 129L, 138L, 90L, 70L,
139L, 120L, 282L, 265L, 205L, 211L, 129L, 185L, 209L, 176L, 185L
)), row.names = c(NA, -949L), class = "data.frame")
Note: I normally wouldn't post such a long example (dt_2
) but I think the nature of the problem warrants it.
回答1:
I am not good at data.table
but here's a tidyverse
way that might help you -
dt_1 %>%
tibble::rownames_to_column("id") %>%
mutate(cj = 1) %>%
inner_join(dt_2 %>% mutate(cj = 1), by = "cj") %>%
select(-cj) %>%
mutate(
closeness = abs(Observed_A - Modeled_A) + abs(Observed_B - Modeled_B),
# closeness = 0 means perfect match
) %>%
arrange(id, closeness) %>%
group_by(id) %>%
slice(1) %>%
ungroup()
# A tibble: 8 x 9
id Observed_A Observed_B Modeled_A Modeled_B Variable_1 Variable_2 Variable_3 closeness
<chr> <dbl> <dbl> <dbl> <dbl> <int> <int> <int> <dbl>
1 1 - 9.70 -3.10 - 9.80 -2.80 4 448 251 0.400
2 2 -10.8 -5.20 -11.4 -5.90 80 865 63 1.30
3 3 - 9.70 -4.50 - 9.80 -4.30 37 857 281 0.300
4 4 - 9.20 -4.10 - 9.80 -4.30 37 857 281 0.800
5 5 - 9.50 -3.00 - 9.80 -2.80 4 448 251 0.500
6 6 -10.1 -2.70 - 9.80 -2.80 4 448 251 0.400
7 7 - 8.30 -2.60 - 8.20 -2.80 86 885 246 0.300
8 8 - 7.60 -2.60 - 8.20 -2.80 86 885 246 0.800
Edit: This method avoids the cross join so shouldn't have memory problems. See if this is fast enough for you. Either way, data.table
should be faster I think.
dt_1 <- dt_1 %>%
tibble::rownames_to_column("id")
dt_2 %>%
slice(
apply(dt_1[,-1], 1, function(x) {
(abs(x[1] - dt_2$Modeled_A) + abs(x[2] - dt_2$Modeled_B)) %>%
which.min()
})
) %>%
mutate(id = as.character(1:nrow(.))) %>%
inner_join(dt_1, ., by = "id")
id Observed_A Observed_B Modeled_A Modeled_B Variable_1 Variable_2 Variable_3
1 1 -9.7 -3.1 -9.8 -2.8 4 448 251
2 2 -10.8 -5.2 -11.4 -5.9 80 865 63
3 3 -9.7 -4.5 -9.8 -4.3 37 857 281
4 4 -9.2 -4.1 -9.8 -4.3 37 857 281
5 5 -9.5 -3.0 -9.8 -2.8 4 448 251
6 6 -10.1 -2.7 -9.8 -2.8 4 448 251
7 7 -8.3 -2.6 -8.2 -2.8 86 885 246
8 8 -7.6 -2.6 -8.2 -2.8 86 885 246
回答2:
Execution Time of Answers Compared
library(ggplot2)
library(dplyr)
library(data.table)
library(microbenchmark)
mbm <- microbenchmark::microbenchmark(
dplyr = dt_2 %>%
slice(
apply(dt_1[,-1], 1, function(x) {
(abs(x[1] - dt_2$Modeled_A) + abs(x[2] - dt_2$Modeled_B)) %>%
which.min()
})
) %>%
mutate(id = as.character(1:nrow(.))) %>%
inner_join(dt_1, ., by = "id"),
data.table = dt_1[, c(.SD, dt_2[which.min(abs(Observed_A-Modeled_A) + abs(Observed_B-Modeled_B))]),
by=dt_2[, seq_len(.N)]],
data.table.reference = dt_1[, names(dt_2) := dt_2[which.min(abs(Observed_A-Modeled_A) + abs(Observed_B-Modeled_B))],
by=dt_1[, seq_len(.N)]])
autoplot(mbm)
Execution Time of Actual Data
I've included this to show the disparity in performance on larger data tables, where dt_1
consists of ~35,000 rows with 30 columns and dt_2
consists of ~15,000 rows and 17 columns.
回答3:
Using the same distance measure as Shree but in data.table (don't think it will be much faster though):
library(data.table)
setDT(dt_1)
setDT(dt_2)
dt_1[, c(.SD, dt_2[which.min(abs(Observed_A-Modeled_A) + abs(Observed_B-Modeled_B))]),
by=dt_1[, seq_len(.N)]]
output:
dt_1 Observed_A Observed_B Modeled_A Modeled_B Variable_1 Variable_2 Variable_3
1: 1 -9.7 -3.1 -9.8 -2.8 4 448 251
2: 2 -10.8 -5.2 -11.4 -5.9 80 865 63
3: 3 -9.7 -4.5 -9.8 -4.3 37 857 281
4: 4 -9.2 -4.1 -9.8 -4.3 37 857 281
5: 5 -9.5 -3.0 -9.8 -2.8 4 448 251
6: 6 -10.1 -2.7 -9.8 -2.8 4 448 251
7: 7 -8.3 -2.6 -8.2 -2.8 86 885 246
8: 8 -7.6 -2.6 -8.2 -2.8 86 885 246
edit: The speed diff might be due to the large number of columns. Another possibility using update by reference:
library(data.table)
setDT(dt_1)
setDT(dt_2)
dt_1[, names(dt_2) := dt_2[which.min(abs(Observed_A-Modeled_A) + abs(Observed_B-Modeled_B))]),
by=dt_1[, seq_len(.N)]]
Or if both dt_1 and dt_2 are matrices, using base R might be faster.
来源:https://stackoverflow.com/questions/56259822/find-nearest-values-of-2-columns-from-a-larger-lookup-style-data-table