# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Function for calculating the net-return for different
#' management scenarios under the selected economic conditions
#' for each location in the data frame. For each point the
#' net-retrun is calculated with the base price, and the
#' opposite system type's base price. If the rate is equal
#' to the farmer selected or the minimum experimental rates, the
#' net-return for those economic conditions are calculated.
#'
#' @param df A matrix with the experimental rate and predicted
#' responses for each data point in the field.
#' @param Bp The base price corresponding to the price for the system
#' type selected by the user (i.e. conventional or organic).
#' @param B0pd The intercept for the protein premium/dockage equation.
#' @param B1pd The coefficient for protein in the protein premium/dockage
#' equation.
#' @param B2pd The coefficient for protein squared for the protein
#' premium/dockage equation.
#' @param B3pd The coefficient for protein cubed for the protein
#' premium/dockage equation.
#' @param CEXP The cost of the experimental input.
#' @param BpOpp The base price corresponding to the price for the opposite
#' system type selected by the user (i.e. conventional or organic).
#' @param FC The fixed costs associated with production per acre, not including
#' the experimental input.
#' @param fs The farmer selected rate or the rate of the experimental
#' input that the farmer would have applied uniformly to the field.
#' @param ssAC The cost of site-specific technology or variable rate
#' application.
#' @param predInd Indicator for whether protein is included or not
#' in the net-return calculations. 1 = yes, 0 = no.
#' @param rr Number of rows in df.
#' @param expCol Indicator for the position of the experimental
#' variable column in df.
#' @param yldCol Indicator for the position of the predicted yield
#' variable column in df.
#' @param proCol Indicator for the position of the predicted protein
#' variable column in df.
#' @param NRcol Indicator for the position of the net-return column
#' in df.
#' @param NRminCol Indicator for the position of the net-return column
#' in df for the minimum experimental rate applied.
#' @param NRoppCol Indicator for the position of the net-return column
#' in df when net-return calculated with the opposite base price as for the
#' system.
#' @param NRfsCol Indicator for the position of the net-return column
#' in df for the farmer selected rate.
#' @param AAmin The minimum experimental rate in the range of rates to
#' simulate in (i.e. 0 lbs N/ac).
#' @return df Matrix filled in with net-returns.
#' @export
NRcalcCpp <- function(df, Bp, B0pd, B1pd, B2pd, B3pd, CEXP, BpOpp, FC, fs, ssAC, predInd, rr, expCol, yldCol, proCol, NRcol, NRminCol, NRoppCol, NRfsCol, AAmin) {
.Call(`_OFPE_NRcalcCpp`, df, Bp, B0pd, B1pd, B2pd, B3pd, CEXP, BpOpp, FC, fs, ssAC, predInd, rr, expCol, yldCol, proCol, NRcol, NRminCol, NRoppCol, NRfsCol, AAmin)
}
#' Function for identifying the optimum full-field experimental rate based on
#' profit maximization. This function selects the optimum rate as
#' the rate where the difference in full-field net-return between
#' experimental rates (first derivitave of the net-return vs. experimental rate
#' function) does not exceed the cost of applying one more unit of
#' the experimental rate across the entire field.
#'
#' This function calculates the optimum rate from the sum of the
#' net-return for a uniform rate applied across the field to
#' identify the full-field optimum rate.
#'
#' See the documentation in OFPE::derivNRoptCpp for a site-specific
#' example of how the optimum is identified compared to when the
#' optimization method is set to 'max'.
#'
#' @param NRff A matrix with rows for each experimental rate and
#' columns for the rate and the full-field net-return calculated
#' under a uniform application of the corresponding rate.
#' @param rr Integer of the number of observations (rows of NRdf).
#' @param fieldsize Double, the size of the field(s) that the
#' experimental input would be applied to.
#' @param CEXP Double, the cost of the experimental input.
#' @return NRffmax, table with the full-field optimum rate
#' and the full-field net-return.
#' @export
derivFFoptCpp <- function(NRff, rr, fieldsize, CEXP) {
.Call(`_OFPE_derivFFoptCpp`, NRff, rr, fieldsize, CEXP)
}
#' Function for identifying the optimum site-specific experimental rate
#' based on profit maximization. This function selects the optimum rate as
#' the rate where the difference in net-return between experimental
#' rates (first derivitave of the net-return vs. experimental rate
#' function) does not exceed the cost of applying one more unit of
#' the experimental rate.
#'
#' This function calculates the optimum rate for every location in
#' the field to identify the site-specific optimum rate.
#'
#' This differs from selecting the rate that yields the highest net-
#' return (selecting 'max' for the optimization method) is highlighted
#' in the following example. The net-return at a point for a rate of X
#' was 120 and the net-return at the point for a rate of X+1 was 121
#' and the cost of one unit of the experimental input was $3.
#' The optimum rate identified in this function would be X, whereas
#' when 'max' is selected X+1 would be the optimum rate because the
#' net-return was higher despite earning less than the cost of the
#' added input.
#'
#' @param NRdf A matrix with rows for each location in the field
#' and columns for the experimental rate applied. Values are the
#' calculated net-returns.
#' @param NRoptDat A matrix with columns for the optimum experimental
#' rate and the associated net-return for each location in the field.
#' This is filled in below.
#' @param Nrates A matrix with one column with each experimental rate
#' in the range specified by the user.
#' @param rr Integer of the number of observations (rows of NRdf).
#' @param cc Integer of the number of experimental rates (rows of Nrates =
#' columns of NRdf).
#' @param CEXP Double, the cost of the experimental input.
#' @return NRoptDat.
#' @export
derivNRoptCpp <- function(NRdf, NRoptDat, Nrates, rr, cc, CEXP) {
.Call(`_OFPE_derivNRoptCpp`, NRdf, NRoptDat, Nrates, rr, cc, CEXP)
}
#' Function for subsetting remotely sensed data from the user
#' selected source. This function takes a matrix with all the
#' remotely sensed data and returns a matrix with the selected
#' data. This function exists because data such as precipitation and
#' vegetation indices are collected from multiple sources, and
#' the user can select the source based on their data preferences.
#'
#' The user also must pass in the column index of the data passed
#' in that corresponds to the primary and secondary source for each
#' variable.
#'
#' @param dat A matrix with all of the remotely sensed data to
#' select from.
#' @param rr The number of rows in dat and df (must be the same).
#' @param prec_cy_1 The column index of the preferred precipitation source for
#' the current year.
#' @param prec_cy_2 The column index of the secondary precipitation source for
#' the current year.
#' @param prec_py_1 The column index of the preferred precipitation source for
#' the previous year.
#' @param prec_py_2 The column index of the secondary precipitation source for
#' the previous year.
#' @param gdd_cy_1 The column index of the preferred growing degree day source
#' for the current year.
#' @param gdd_cy_2 The column index of the secondary growing degree day source
#' for the current year.
#' @param gdd_py_1 The column index of the preferred growing degree day source
#' for the previous year.
#' @param gdd_py_2 The column index of the secondary growing degree day source
#' for the previous year.
#' @param veg_cy_1 The column index of the preferred vegetation index source
#' for the current year.
#' @param veg_cy_2 The column index of the secondary vegetation index source
#' for the current year.
#' @param veg_py_1 The column index of the preferred vegetation index source
#' for the previous year.
#' @param veg_py_2 The column index of the secondary vegetation index source
#' for the previous year.
#' @param veg_2py_1 The column index of the preferred vegetation index source
#' for two years prior.
#' @param veg_2py_2 The column index of the secondary vegetation index source
#' for two years prior.
#' @return df Returns a completed table with selected data.
#' @export
selectDatCpp <- function(dat, rr, prec_cy_1, prec_cy_2, prec_py_1, prec_py_2, gdd_cy_1, gdd_cy_2, gdd_py_1, gdd_py_2, veg_cy_1, veg_cy_2, veg_py_1, veg_py_2, veg_2py_1, veg_2py_2) {
.Call(`_OFPE_selectDatCpp`, dat, rr, prec_cy_1, prec_cy_2, prec_py_1, prec_py_2, gdd_cy_1, gdd_cy_2, gdd_py_1, gdd_py_2, veg_cy_1, veg_cy_2, veg_py_1, veg_py_2, veg_2py_1, veg_2py_2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.