Skip to contents

These functions switch code blocks on/off.

Usage

patter_run(.julia = TRUE, .geospatial = TRUE)

patter_run_expensive()

Arguments

.julia

A logical variable that defines whether or not the code requires connection to a Julia session.

.geospatial

A logical variable that defines whether or not R's geospatial packages (e.g., terra) are required.

Value

The functions return a logical value.

Details

patter_run() is the main switch:

  • If .julia = TRUE, the 'switch' is off if:

    • AUTO_JULIA_INSTALL != "true";

    • You are on a Linux platform and geospatial packages are currently in use;

    • You are on a Linux platform and .geospatial = TRUE;

  • Otherwise, the switch if off if:

    • You are on a Linux platform, JULIA_SESSION = "TRUE" and .geospatial = TRUE;

(On Linux, geospatial libraries cannot be used simultaneously in R and Julia.)

patter_run_expensive() is a subsidiary switch for particularly expensive routines:

  • If PATTER_RUN_EXPENSIVE = "TRUE", this returns TRUE;

  • Otherwise, FALSE is returned;

Author

Edward Lavender

Examples

if (patter_run(.julia = TRUE, .geospatial = TRUE)) {
  # Connect to `Julia` session
  julia_connect()
  # Use a geospatial library in `R`
  map <- dat_gebco()
  terra::plot(map)
  # Set the map in `Julia`
  set_map(map)
}
#> `patter::julia_connect()` called @ 2025-04-22 09:31:01... 
#> ... Running `Julia` setup via `JuliaCall::julia_setup()`... 
#> ... Validating Julia installation... 
#> ... Setting up Julia project... 
#> ... Handling dependencies... 
#> ... `Julia` set up with 11 thread(s). 
#> `patter::julia_connect()` call ended @ 2025-04-22 09:31:01 (duration: ~0 sec(s)).