The snippet tries to write a temp file, but if you can't launch R at all, then you wouldn't be able to run it.
Can you run this from powershell or CMD? "C:\Program Files\R\R-4.0.2\bin\Rscript.exe" -e "tempdir()"
You would need to sub in your own location of Rscript.exe.
And then do you have write permissions on a folder that looks like this? C:\Users\ethan\AppData\Local\Temp