It is possible to create graphs using R from a Java program. Let's look at SimplePlot.java:
- In the main method, first we create an Rengine instance and check whether the R session is created successfully.
- We set the working directory in R, either from the last argument that was passed while executing the command, or from the current user directory from where the Java command was executed. The args.length == 0 array indicates that no argument is passed during the execution of the code, and hence, we use the user directory as the R working directory.
- We use the read.csv function to read the file in R and load it into an R variable, auto.
- We use the nrow function to get the number of rows in auto, and print the value.
- We set ...