RCaller: Is Tree Height and Tree Width Correlated?

Liz Sanderson
Liz Sanderson
  • Updated

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.

sourcedata.jpg

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.

rcallerparameters.jpg

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.

rcaller-logger-log.jpg

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.