function silently changes the length of its return vector depending on tree characteristics
- Dominant language
- R
- Stars
- 1
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Description:
In R/treeProfile.R, the code that computes merchantable volume returns a 0-row data.table when the filter matches no rows. This causes downstream logic to fail because it expects a single-row summary with Value = 0.
treeprofiledata[HT_I %>=% stumpHeight & DIB_I_next %>=% UTOPDIB,
.(Name = "VOL_MER", Value = sum(VOL_I, na.rm = TRUE))]
When the filter returns zero rows, the result is an empty data.table.
Expected behavior:
Always return a single-row summary, even when no rows match the filter.
Suggested fix:
data.table(Name = "VOL_MER",
Value = sum(treeprofiledata[HT_I %>=% stumpHeight &
DIB_I_next %>=% UTOPDIB, VOL_I],
na.rm = TRUE))
This ensures:
sum() returns 0 when no rows match
The output is always a single-row data.table
Downstream code receives consistent structure
File reference
R/treeProfile.R
Local path: C:/FAIBBase/R/treeProfile.R
Contributor guide
Research direction
Open R/treeProfile.R and locate the merchantable-volume calculation using the HT_I, stumpHeight, DIB_I_next, and UTOPDIB filter. Check the result when no rows match, then verify that the calculation consistently returns one row with Name set to VOL_MER and Value set to 0, without breaking downstream logic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100