Files
-
- 2 MB
- Download
Introduction
The RCaller allows users to run R scripts in FME. In this demo, we aim to determine whether there is a correlation between the height of trees and their diameter.
Source Data
The CSV file, PublicTrees.csv, contains various attributes regarding trees in a city.
Step-by-step Instructions
The download Correlation_Tree_Height_Diameter.fmwt is the complete workspace. If you would like to create the workspace yourself, please download PublicTrees.csv and follow the steps below to set it up.
1. Read Source Data
Read the PublicTrees.csv using a CSV Reader.
2. Add a RCaller
For the RScript, please specify the following:
Correlation=cor(CSV$Diameter, CSV$Height, method = "pearson")
fmeOutput<-data.frame(Correlation)The cor() function will calculate the correlation between tree height and tree diameter. If it is desirable to work with the attribute created during the R Script, in this case Correlation, it is necessary to expose it in the Attributes to Expose parameter or in an AttributeExposer transformer following the RCaller.
Please expose the attribute Correlation in the Attributes to Expose parameter.
3. Examine the Result
Add a logger after the RCaller and run the workspace. In the log file, the Correlation is reported as 0.48002325189223527. This value indicates a moderate relationship between tree height and tree diameter. A value closer to 1 or -1 would indicate a stronger correlation between height and diameter. Tree genus or species may be a factor to consider, and it is possible to filter based on either. This may indicate that a specific tree genus or species has a stronger correlation between tree height and diameter.