I want to inverse a torque model of a typical combustion engine which is currently in a IQ (injection quantity) to NM (newtonmeter) format to a torque model with a NM to IQ format.
The current torque model has the injection quantity in the columns and the engine RPM in the rows, with in each respective cell the torque the engine produces given the engine RPM and injection quantity. I want to switch the injection quantity with the torque, such that the torque the engine produces is in each column and the injection quantity necessary to produce the NM given the specific engine RPM is in the cells.
The problem is that, in order to this, I need to perform linear interpolation within the two nearest cells. I have tried to do this with an INDEX / MATCH in Excel, but the issue is that this function only returns the nearest IQ for the respective NM. Also, inversing the table does not do the trick in Excel.
As such, this is the R code to import the original IQ to NM table (which I want to convert to a NM to IQ table):
TorqueModelIQtoNM <- structure(list(`0` = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), `1` = c("7.1", "7.1", "7.4",
"6.7", "6.5", "6.5", "6.7", "6.9", "6.3", "6.3", "6.1", "6.1",
"5.9", "6.5", "6.5", "6.5", "6.5", "6.5"), `3` = c("21.4", "21.4",
"22.3", "20", "19.4", "19.4", "20", "20.7", "18.8", "18.8", "18.2",
"18.2", "17.6", "19.4", "19.4", "19.4", "19.4", "19.4"), `5` = c("35.7",
"35.7", "37.7", "33.8", "32.7", "30.9", "31.8", "34.5", "30.9",
"31.3", "28.9", "28.9", "27.6", "29.3", "31.9", "31.9", "31.9",
"31.9"), `8` = c("56.3", "56.6", "60.4", "55", "53", "54", "53.3",
"55", "47.1", "47.3", "47.9", "49.6", "44", "55", "55.6", "51.6",
"50.2", "50.6"), `10` = c("68.8", "69.4", "71.8", "68", "69.2",
"65.2", "66.3", "67.5", "59.6", "57.8", "62.5", "62.8", "59.7",
"65.3", "67.1", "64.4", "62.2", "62.2"), `15` = c("94.7", "94.8",
"96.6", "99", "99.4", "101.6", "103.5", "102.8", "99.4", "93.4",
"90.6", "89", "86.7", "93.8", "93.4", "92.2", "92.9", "92.5"),
`20` = c("116", "116.7", "122.5", "123.8", "127.8", "126.7",
"131.4", "127.4", "126.4", "123.5", "123.1", "116.4", "113.6",
"120.5", "123.3", "121.6", "122.3", "120.9"), `22.5` = c("122.5",
"122.9", "135.7", "137.3", "141.4", "140", "143.3", "140.8",
"139.2", "136.5", "136.8", "133.9", "131.8", "133.2", "136.8",
"133.8", "133.2", "132.2"), `25` = c("129", "129", "147.6",
"150", "154.3", "153.7", "155.8", "155", "151.9", "150",
"149", "150", "146.5", "146.8", "150", "147.3", "144.5",
"143.3"), `27.5` = c("146.2", "146.2", "157.4", "165", "167.2",
"167.2", "168.2", "170.6", "164.4", "165.9", "162.8", "164.3",
"161.4", "161.9", "161.3", "160", "155.7", "154.5"), `30` = c("160",
"160", "165.1", "179.2", "181.9", "181.9", "181.1", "185.4",
"178.3", "178.6", "176.7", "177.4", "173.1", "174", "169.7",
"169.4", "165.9", "165.1"), `32.5` = c("169.4", "169.4",
"172.2", "191.1", "195.5", "196.3", "193.6", "195", "191.8",
"190.6", "189.8", "188.2", "185.3", "182", "178.3", "179.3",
"177.9", "175"), `35` = c("181.7", "181.7", "182.5", "200.8",
"208.7", "212.1", "206", "207.9", "206.4", "204.7", "201.6",
"197.6", "192.9", "189.5", "190.8", "198.9", "200.3", "200.3"
), `37.5` = c("198.8", "198.8", "198.8", "209.3", "219.8",
"225", "220.2", "222.6", "217.9", "214.4", "212.3", "208.3",
"205", "199.8", "207", "212.5", "214.9", "214.9"), `40` = c("215.8",
"212.9", "213.3", "224.7", "234.3", "237.7", "234.1", "235.0",
"232.2", "228.1", "226.6", "224.0", "221.2", "220.7", "222.6",
"225.8", "226.6", "226.1"), `42.5` = c("225.65", "224.13",
"224.59", "239.47", "250.02", "254.24", "249.46", "250.54",
"247.92", "243.81", "242.13", "238.12", "234.55", "231.31",
"234.73", "239.86", "241.50", "240.92"), `47.5` = c("251.90",
"249.86", "248.33", "264.69", "277.68", "283.17", "276.99",
"277.76", "275.89", "270.50", "268.85", "263.62", "259.97",
"255.59", "260.54", "267.33", "270.30", "269.91"), `57.5` = c("298.95",
"297.62", "302.53", "326.40", "339.64", "344.43", "339.06",
"340.72", "337.27", "333.32", "330.29", "325.89", "321.19",
"315.30", "317.62", "323.49", "323.80", "322.37")), class = "data.frame", row.names = c(800L,
1000L, 1250L, 1500L, 1750L, 2000L, 2250L, 2500L, 2750L, 3000L,
3250L, 3500L, 3750L, 4000L, 4250L, 4500L, 4750L, 5000L))
Would anyone know an R function which can perform this exercise?