This function prepares a dataframe for analysis. It summarizes the data in a dataframe according to user-defined groups and functions (mean, frequency, intensity, etc.). For instance, it allows you to calculate the intensity and frequency of disease attack per plot. If the user wants to use the raw data, a "raw" parameter allows you to keep all the data from the initial dataframe. The data is enriched by default with descriptions of the plots and treatments.
Utilisation
prepare_data(
self,
df,
var_cols = NULL,
group_cols = "plot_id",
funs = list(intensite = intensity, frequence = incidence),
filters = NULL,
code_tnt = "TNT",
raw = FALSE,
tnt_mode = "all",
add_plot_desc = TRUE,
flex = NULL,
add_trt_desc = TRUE,
prep_name = NULL,
prep_desc = NULL
)
Arguments
- self
an instance of the
UserData
R6 class containing observation data.- df
the name of observation dataframe to prepare
- var_cols
character, colname(s) of the variable to use in data
- group_cols
colnames for grouping
- funs
vector of statistics to be applied, by default c("intensity","incidence")
- filters
a list of filters to apply. for instance : list(xp_trt_name = c("TNT","MOD1"), block_code = "A") will keep only block_code = A and xp_trt_name = TNT or MOD1.
- code_tnt
for efficacy only : a string to identify in TNT in the row of the dataframe by default "TNT"
- raw
boolean, if TRUE the dataframe returned contains all values without summarize, that means funs is ignored
- tnt_mode
(for efficacy calculation only) : mode of association of plot and tnt. a character value among "block","nearest","all","user". by default set to "all".
- add_plot_desc
boolean. if TRUE, the dataframe is merged with plot description found in the sheet "placette"
- flex
boolean. if TRUE, 10A A1O or 10a are considered as the same plot_id. if NULL, flex is automatically adjusted when a difference in plot_id is detected
- add_trt_desc
boolean. if TRUE, the dataframe is merged with experimental treatment description found in the sheet "modalite"
- prep_name
name of the prepared dataset
- prep_desc
short description of the prepared dataset
Valeur de retour
a dataframe with group_cols and including a 'calculation' column which specifies the name of the functions applied to the variable and a 'value' column which gives the calculated values.
Détails
For efficacy calculation, tnt_mode could be one among :
"all" : efficacy is calculated with the mean value of all TNT
"block" : efficacy is calculated with the mean value of TNT per block
"nearest" : efficacy is calculated with the nearest TNT to the plot
"user" : efficacy is calculated with an association table between TNT and plot provided by the user (to import in (data_user)$plot_tnt_association$user_association)