How to detect cheating when students take online quizzes or exams from home?
I also teach a data and programming course, though I mainly use Python.

Is it possible for you to shift grading away from an exam and toward something else?  A project, for example?  Before going back to academia I spent years working as a policy researcher, and exam conditions simply aren't a realistic test of real-life coding abilities.  For that matter, coding with the internet turned off is also not remotely what real work looks like either.

In my class I like to give a larger project and let them have a few weeks to work on it, but I could also imagine a more simple project that they only have a few days, or even hours, to do.  Real data work often comes with time constraints, but it does not come with a lack of internet access in exam-like conditions.  Just scale the scope of the project based on how long you want them to have to work on it.

There is still a huge advantage to knowing the material, rather than having to look it up.  You can also grade on the quality of code and correctness of results, and allow for creativity with open-ended questions like "summarize this data with two plots".  This way each student is not only tested their knowledge of R, they're tested on their actual ability to use R in a realistic environment.

If you, unfortunately, are required to give an exam, I know there is software available for proctoring online tests.  The sort of thing that utilizes their webcams to make sure they don't leave during the test, or consult other devices, or open other web pages.  I've not used them though, so I couldn't make a recommendation.  I imagine they all require university subscriptions.