Learn R Programming

ofpetrial: Design on-Farm Precision Experiments

The ofpetrial package allows the user to design agronomic input experiments in a reproducible manner without using ArcGIS or QGIS. The vignette for this package provides more detailed guidance on how to use the package.

Installation

CRAN version

You can install the CRAN version of the ofpetrial package.

install.packages("ofpetrial")

Development version

You can install the development version of ofpetrial from Github:

devtools::install_github("DIFM-Brain/ofpetrial")

Example

Here, we demonstrate how to use the ofpetrial package to create a single-input on-farm experiment trial design (more detailed instructions on the basic workflow is provided in this article).

library(ofpetrial)

Create experimental plots

We start with specifying plot and machine information for inputs using prep_plot.

n_plot_info <-
  prep_plot(
    input_name = "NH3",
    unit_system = "imperial",
    machine_width = 30,
    section_num = 1,
    harvester_width = 30,
    plot_width = 30
  )
#> 

Now, we can create experiment plots based on them using make_exp_plots().

exp_data <-
  make_exp_plots(
    input_plot_info = n_plot_info,
    boundary_data = system.file("extdata", "boundary-simple1.shp", package = "ofpetrial"),
    abline_data = system.file("extdata", "ab-line-simple1.shp", package = "ofpetrial"),
    abline_type = "free"
  )
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0;
#> sf_use_s2() is TRUE
#> Warning: There was 1 warning in `dplyr::mutate()`.
#> ℹ In argument: `experiment_plots_dissolved = list(...)`.
#> ℹ In row 1.
#> Caused by warning:
#> ! package 'sf' was built under R version 4.2.3

viz(exp_data, type = "layout", abline = TRUE)

Assign rates

We first prepare nitrogen rates.

#!===========================================================
# ! Assign rates
# !===========================================================
n_rate_info <-
  prep_rate(
    plot_info = n_plot_info,
    gc_rate = 180,
    unit = "lb",
    rates = c(100, 140, 180, 220, 260),
    design_type = "ls",
    rank_seq_ws = c(5, 4, 3, 2, 1)
  )

dplyr::glimpse(n_rate_info)
#> Rows: 1
#> Columns: 12
#> $ input_name          <chr> "NH3"
#> $ design_type         <chr> "ls"
#> $ gc_rate             <dbl> 180
#> $ unit                <chr> "lb"
#> $ tgt_rate_original   <list> <100, 140, 180, 220, 260>
#> $ tgt_rate_equiv      <list> <82.0, 114.8, 147.6, 180.4, 2…
#> $ min_rate            <lgl> NA
#> $ max_rate            <lgl> NA
#> $ num_rates           <int> 5
#> $ rank_seq_ws         <list> <5, 4, 3, 2, 1>
#> $ rank_seq_as         <list> <NULL>
#> $ rate_jump_threshold <lgl> NA

We can now use assign_rates() to assign rates to experiment plots.

trial_design <- assign_rates(exp_data, rate_info = n_rate_info)

Here is the visualization of the trial design done by viz.

viz(trial_design)

Along with the spatial pattern of the input rates, the applicator/planter ab-line and harvester ab-line are drawn by default.

Write the trial design files for implementation

You can write out the trial design as a shape file.

write_trial_files(td)

Acknowledgement

This project was funded in part by a United States Department of Agriculture—National Institute of Food and Agriculture (USDA—NIFA) Food Security Program Grant (Award Number 2016-68004-24769) and by United States Department of Agriculture (USDA) -Natural Resources Conservation Service (NRCS), Commodity Credit Corporation (CCC), Conservation Innovation Grants On-Farm Conservation Innovation Trials (Award Number USDA-NRCS-NHQ-CIGOFT-20-GEN0010750).

Copy Link

Version

Install

install.packages('ofpetrial')

Monthly Downloads

244

Version

0.1.2

License

GPL (>= 3)

Maintainer

Taro Mieno

Last Published

December 11th, 2024

Functions in ofpetrial (0.1.2)

check_ortho_with_chars

Check the orthogonality with field/topographic characteristics
change_rates

Change the assigned rates
prep_rate

Create data of input rate information for a single input
exp_data

Experiment data
make_trial_report

Create trial design report
td_two_input

Trial design (two-input)
viz

Visualize various aspects of a trial design
ofpetrial-package

ofpetrial: Design on-Farm Precision Field Agronomic Trials
plot_info

Plot information
rate_info

Rate information
prep_plot

Prepare plot information for a single-input experiment (length in meter)
%>%

Pipe operator
write_trial_files

Write trial design files for field implementation
check_ortho_inputs

Check the correlation of the two inputs
make_exp_plots

Make experimental plots/strips inside the field boundary
assign_rates

Assign rates to the plots of experimental plots
add_blocks

Add blocks to trial design
check_alignment

Check the alignment of harvester and applicator/planter
assign_rates_conditional

Assign rates to the plots of experimental plots for a single input based on existing trial designs created by assign_rates()
td_curved

Trial design (single-input) for a curved field
td_single_input

Trial design (single-input)