Primary TPS on the parts fiche, #2 here, the new ones have a blue inside, they last a long time usually, much longer than the older ones:
ThrottlesInjectors amp Fuel Rail
This is on the end of the TBs by your left knee, NOT the one on the radiator side of the TBs (that's the secondary and can be completely ignored with removed secondary plates).
TuneECU has a TPS adjustment feature. When following the instructions for it, substitute 0.68 for the part where it says to get to 0.60-0.62. I've tried this on multiple R3s now and they always run better with .68 instead of .60-.62.
This voltage tells the ECU you are at true 0% throttle. When it's set to 0.68 instead of 0.6, the slightest motion of the throttle now registers to the ECU. With 0.6 setting, there is slop between physically closed throttle and just slightly open where the ECU still receives a "fully closed" signal. This mismatch between physical open amount and ECU signal screws up fueling and ignition timing.
With a failing sensor, it will stick in places at a certain voltage. So, for example, if you go to 50% throttle but the sensor only sends a 15% throttle because it's a bad sensor, fueling/ignition will be completely wrong for the amount of air being ingested and the bike will hesitate/buck/cough etc.
TPS adjustment instructions here:
Connect TuneECU, bike power on, not running.
Tests page of TuneECU.
Double click "Adjust ISCV".
Listen to wonky noises until it's done moving things. Now look at ISCV voltage.
Loosen the single screw that fixes the primary TPS, and rotate gently until the displayed voltage is 0.68v, secure single bolt.
Double click to continue.
Verify by doing it a second time, or as many times as are necessary to get ISCV voltage to 0.68 when fully open during the Adjust ISCV process.
The process for adjusting the stalling while coasting with clutch pulled/in neutral is another issue, but do this first as it may fix it