python_to_r function

Convert Python code to R code