2

I have a R script code as below and it is working well for R commands for which it shows the output of eval expression in the html file, however when I replace the expression with R command which evaluates the python file it shows the output on the console and not in the html file.

Below is the script which works

listfile<-"temp.html"  # Create temp.html file in current directory 
listcon <- file(listfile, "w")
sink(listcon, append = TRUE, type = "output", split = split)
eval(parse(text="print('hello')"))  # Evaluate the expression and shows the output on html file
close(listcon)

however, if I only change the eval expression as shown below, it shows the output on the console but not on the html file.

listfile<-"temp.html"
listcon <- file(listfile, "w")
sink(listcon, append = TRUE, type = "output", split = split)
eval(parse(text="py_run_file('code.py')")) # This line now shows the output in console but not in the browser
close(listcon)

Below is the code in code.py

print('Python hello code')

My folder structure is as below:

|
|- script.R
|- code.py
|- temp.html

Thanks for your time and suggestion.

Pawan Rama Mali
  • 526
  • 2
  • 9

0 Answers0