This function translates one or more columns of ICESAcousticData to new values given by the input Translation.

TranslateICESAcoustic(
  ICESAcousticData,
  TranslationDefinition = c("FunctionParameter", "FunctionInput"),
  VariableName = character(),
  Conditional = FALSE,
  ConditionalVariableNames = character(),
  TranslationTable = data.table::data.table(),
  Translation,
  PreserveClass = TRUE
)

Arguments

ICESAcousticData

ICESAcousticData.

TranslationDefinition

The method to use for defining the Translation, one of FunctionParameter to define the Translation on the fly in this function using the TranslationTable, or FunctionInput to import Translation process data from a previously run process using the function DefineTranslation. When reading the translation from a file FunctionInput must be used.

VariableName

The name of the variable to translate. This will be the name of the first column of the TranslationTable when generated from the StoX GUI.

Conditional

Logical: If TRUE condition the translation on values of other variables.

ConditionalVariableNames

The names of the variables to condition the translation on. Must be given if Conditional == TRUE. This will be the name(s) of the third column and onwards of the TranslationTable when generated from the StoX GUI.

TranslationTable

A table holding the following columns: The first column holds the values to translate FROM, the second column holds the values to translate TO, and the remaining zero or more columns holds the values for the conditional variables specified in ConditionalVariableNames. I.e., if VariableName = "IndividualAge" and ConditionalVariableNames = "IndividualSex", and the TranslationTable has values 3, 4 and "F" in the first row, female fish at age 3 are translated to age 4. Use NA to translate missing values (shown as "-" in Preview in the StoX GUI, and usually as empty cell in excel). Values in the TranslationTable can be given either as single values or as expressions of functions of the variable specified by the column name. See details of DefineTranslation.

Translation

Translation.

PreserveClass

Logical: If TRUE (the default) do not convert the class of the data by the class of the translation table. E.g., with the default (PreserveClass = TRUE), if the variable to translate is integer (1, 2, etc) and the NewValue is character ("First", "Second", etc), the NewValue will be converted to integer before translation, resulting in NA if the character strings are not convertible to integer. In this example it could be the user's intention to convert the class of the variable to translate instead, which is possible using PreserveClass = FALSE.

Value

A ICESAcousticData object.