RCaller: Is Tree Height and Tree Width Correlated?

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2016.x


The RCaller allows users to run R scripts in FME. In this demo, we would like to determine whether or not there is a correlation between the height of trees and the diameter of trees.


Source Data

The CSV file, PublicTrees.csv, contains various attributes regarding trees in a city.


Source CSV data viewed with Data Inspector


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 create it.

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")


The cor() function will calculate the correlation between tree height and tree diameter. If 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.


RCaller parameters


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 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 some tree genus or species has a stronger correlation between tree height and tree diameter.


Logged RCaller output

Was this article helpful?



Please sign in to leave a comment.