recipe.sf {tidysdm}R Documentation

Recipe for sf objects

Description

This method for recipes::recipe() handles the case when x is an sf::sf object, as commonly used in Species Distribution Model, and generates a spatial_recipe.

Usage

## S3 method for class 'sf'
recipe(x, ...)

spatial_recipe(x, ...)

Arguments

x

An sf::sf data frame.

...

parameters to be passed to recipes::recipe()

Details

recipes are not natively compatible with sf::sf objects. The problem is that the geometry column of sf::sf objects is a list, which is incompatible with the translation of formulae in recipe. This method strips the geometry column from the data.frame and replaces it with a simple X and Y columns before any further operations, thus allowing the usual processing by recipe() to succeed (X and Y are give the role of coords in a spatial recipe). When prepping and baking a spatial_recipe, if a data.frame or tibble without coordinates is used as training or new_data, dummy X and Y columns are generated and filled with NAs. NOTE that order matters! You need to use the syntax recipe(x=sf_obj, formula=class~.) for the method to successfully detect the sf::sf object. Starting with formula will fail.

Value

An object of class spatial_recipe, which is a derived version of recipes::recipe , see the manpage for recipes::recipe() for details.


[Package tidysdm version 0.9.4 Index]