Fixing tuning.r to work with single-raster models#1
Open
darcyj wants to merge 1 commit intocran:masterfrom
Open
Fixing tuning.r to work with single-raster models#1darcyj wants to merge 1 commit intocran:masterfrom
darcyj wants to merge 1 commit intocran:masterfrom
Conversation
Before this change, ENMevaluate does NOT work when forming a model using a single raster layer. NOTE: this is NOT the same issue that arises when a single raster layer is used instead of a raster stack with only one layer in it. That's a different problem. The bug I'm fixing here occurs when env (the input to tuning() ) is a raster stack containing one raster. Instead, there's some data.frame subsetting that happens within the tune() function that assumes a 2-dimensional data.frame. Usually that's fine, until you only have one raster layer and therefore the data.frame objects "train.val", "test.val" and "bg.val" each have a single column. When they are subset using [some_logical, ], R( in its infinite wisdom) returns a vector, NOT a data.frame. This is solved by adding "drop=FALSE", which I've done here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this change, ENMevaluate does NOT work when forming a model using a single raster layer.
NOTE: this is NOT the same issue that arises when a single raster layer is used instead of a raster stack with only one layer in it. That's a different problem. The bug I'm fixing here occurs when env (the input to tuning() ) is a raster stack containing one raster.
Instead, there's some data.frame subsetting that happens within the tune() function that assumes a 2-dimensional data.frame. Usually that's fine, until you only have one raster layer and therefore the data.frame objects "train.val", "test.val" and "bg.val" each have a single column. When they are subset using [some_logical, ], R( in its infinite wisdom) returns a vector, NOT a data.frame. This is solved by adding "drop=FALSE", which I've done here.