PrepareERA.Rd
This function prepares the ERA dataset for the analysis of outcome ratios. Several actions are applied:
Where a lower value indicates a better outcome, the outcome values for control (MeanC) and treatment (MeanT) are swapped. This excludes economic outcomes. A logical column MeanFlip is added to the output dataset to indicate if outcome values have been swapped. Response ratios (yi) and percentage change (pc) are recalculated.
Non-ERA practices (h-codes) are removed from the base.practice list (eventually this will be moved to compilation).
Rows with blank practice names (PrName) are filtered from the supplied dataset.
The inverse of efficiency outcomes that are In/Out (267.1 and 265.1) is taken (1/value) and the outcome code (267 & 265) and naming columns are renamed accordingly.
Outcomes with a percentage of negative values > Perc.Neg are filtered from the supplied dataset.
Practice names (PrNames) can optionally be be encoded and output as combinations. For more details see the DoCombinations and CombineAll parameter descriptions.
PrepareERA(
Data,
CombineAll = F,
DoCombinations = F,
Perc.Neg = 0.5,
RmNeg = T,
Invert2xNeg = T,
PLevel = "Practice",
Delim = "-",
Cols = c("Code", "Country", "Latitude", "Longitude", "Site.Type", "ID", "Site.ID",
"Rep", "Diversity", "Tree", "Variety", "Duration", "M.Year", "EU", "EUlist",
"Outcode", "MeanC", "MeanC.Error", "MeanT", "MeanT.Error", "Mean.Error.Type",
"Units", "TID", "CID", "MeanFlip", "Neg.Vals", "plist", "base.list", "Product",
"Product.Type", "Product.Subtype", "Product.Simple", "Out.Pillar", "Out.SubPillar",
"Out.Ind", "Out.SubInd", "SubPrName", "PrName", "Theme", "SubPrName.Base",
"PrName.Base", "T.Descrip", "C.Descrip",
"C.NI", "C.NO", "T.NI", "T.NO",
"Partial.Outcome.Name", "Partial.Outcome.Code", "DataLoc")
)
The compiled ERA dataset
Logical T/F
. Applies only when DoCombinations is TRUE.
When set to TRUE all rows containing a practice (alone or in combination with other practices) are copied to the
Data.Combos table and renamed. When set FALSE only the rows of a practice where it occurs in combination with other practice are copied to the Data.Combos table and renamed.
Default = F.
Logical T/F
. When set to TRUE rows with >1 experimental practice are duplicated for the number of practices present and PrName/SubPrName fields changed to one of those practices
(e.g. if PrName is Mulch-BioChar then the row is duplicated (n=2) with PrName in row 1 as Mulch and in row 2 as BioChar). The copied rows are joined and the function output changes to a list of two data.tables, "Data"
and "Data.Combos" . Note ONLY the PrName/SubPrName field is changed in the Data.Combos table, all other fields remain the same. Default = F
.
A numeric vector of length one defining the maximum percentage of negative values allowed for an outcome x practice combination. If an outcome x practice has a higher percentage of negative values than Perc.Neg
it is filtered from the dataset. Default = 0.5.
Swaps MeanT and MeanC values where they are both negative. Less negative values become better than more negative values.
choose Practice
or Subpractice
to determine hierarchical level at which practice combinations are detected. To make the function more generalizable you can also include the column name of a field here.
Character. The delimter that separates multiple names within a character string (for example the delimiter -
separates two practices in the string Inorganic Fertilizer-Organic Fertilizer
)
A vector of column names to retain from the ERA dataset supplied. Default values are supplied.
If DoCombinations = F a data.table of the processed ERA dataset. If DoCombinations = T a list of two data.tables, "Data" as per combinations = F and "Data.Combos" where PrNames/SubPrName have been modified to reflect combination practices.