Using Python in R with the Reticulate Package and Integration with Shiny

The Data Intensive Farm Management (DIFM) project is funded through a grant by the USDA-NRCS. In order to enable farmers to design their own experiments, to optimize management decisions for local conditions, I created a Shiny App, where the background code for creating the Wheat trials was written in Python. The farmers will enter in site-specific inputs, and in return receive files they can put in their tractor in order to perform the experimental design. In this presentation I discussed how I incorporated the Python code in Shiny using the Reticulate package in R. During this presentation I discussed what Recticulate is, how to set up a Python environment, and the complications I ran into while doing so. The main one being, that R was trying to connect to a Python version that no longer existed on my computer. To fix this, I had to install an older version of Reticulate. Next, I had to then had to run the Python code, given the Shiny Inputs. I first sourced the necessary file to have access to all the Python functions in the Shiny session. Then, I created a dictionary of the Shiny inputs, and put these into the Python class Field. Then I ran the main function of the Field python class with the dictionary of inputs in order to develop the experimental design. User’s are then able to view the design, and then download it if they are satisfied with it. The slides give some pictures of an older version of this app, the current app (still being tested) can be found at: http://trialdesign.difm-cig.org/


