Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datsusc #345

Merged
merged 10 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ jobs:
tag: ${{ env.FINAL_TAG }}
name: ${{ env.FINAL_TAG }}
artifacts: ${{ env.PKG_REPO }}/${{ env.PKG_FREL }}
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RstoxData
Version: 1.10.2-9003
Date: 2023-11-22
Date: 2023-11-23
Title: Tools to Read and Manipulate Fisheries Data
Authors@R: c(
person(given = "Edvin",
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export(CopyBiotic)
export(CopyICESAcoustic)
export(CopyICESBiotic)
export(CopyICESDatras)
export(CopyICESDatsusc)
export(CopyLanding)
export(CopyStoxAcoustic)
export(CopyStoxBiotic)
Expand All @@ -21,13 +22,15 @@ export(FilterBiotic)
export(FilterICESAcoustic)
export(FilterICESBiotic)
export(FilterICESDatras)
export(FilterICESDatsusc)
export(FilterLanding)
export(FilterStoxAcoustic)
export(FilterStoxBiotic)
export(FilterStoxLanding)
export(ICESAcoustic)
export(ICESBiotic)
export(ICESDatras)
export(ICESDatsusc)
export(MergeAcoustic)
export(MergeStoxAcoustic)
export(MergeStoxBiotic)
Expand All @@ -45,6 +48,7 @@ export(TranslateBiotic)
export(TranslateICESAcoustic)
export(TranslateICESBiotic)
export(TranslateICESDatras)
export(TranslateICESDatsusc)
export(TranslateLanding)
export(TranslateStoxAcoustic)
export(TranslateStoxBiotic)
Expand Down
33 changes: 33 additions & 0 deletions R/Copy.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,39 @@ CopyICESDatras <- function(
return(ICESDatrasDataCopy)
}

##################################################
#' Copy a variable of ICESDatrasData
#'
#' This function copies a variable to another (possibly existing) variable of \code{\link{ICESDatrasData}} .
#'
#' @inheritParams ModelData
#' @inheritParams copy_arguments
#'
#' @return
#' A \code{\link{ICESDatrasData}} object.
#'
#' @export
#'
CopyICESDatsusc <- function(
ICESDatsuscData,
FromVariable = character(),
ToVariable = character(),
Overwrite = FALSE,
PreserveClass = TRUE
) {
# Make a copy, as we are copying by reference:
ICESDatsuscDataCopy <- data.table::copy(ICESDatsuscData)

copyData(
data = ICESDatsuscDataCopy,
fromVariable = FromVariable,
toVariable = ToVariable,
overwrite = Overwrite,
preserveClass = PreserveClass
)

return(ICESDatsuscDataCopy)
}

##################################################
#' Copy a variable of AcousticData
Expand Down
41 changes: 41 additions & 0 deletions R/DefineAndUpdateVariables.R
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,47 @@ TranslateICESDatras <- function(
return(ICESDatrasDataCopy)
}

##################################################
#' Translate ICESDatsuscData
#'
#' This function translates one or more columns of \code{\link{ICESDatsuscData}} to new values given by the input \code{Translation}.
#'
#' @inheritParams DefineTranslation
#' @inheritParams ModelData
#' @inheritParams ProcessData
#' @inheritParams TranslateStoxBiotic
#'
#' @return
#' A \code{\link{ICESDatsuscData}} object.
#'
#' @export
#'
TranslateICESDatsusc <- function(
ICESDatsuscData,
TranslationDefinition = c("FunctionParameter", "FunctionInput"),
VariableName = character(),
Conditional = FALSE, # If TRUE, adds a column to the parameter format translationTable.
ConditionalVariableNames = character(),
TranslationTable = data.table::data.table(),
Translation,
PreserveClass = TRUE
) {
# Make a copy, as we are translating by reference:
ICESDatsuscDataCopy <- data.table::copy(ICESDatsuscData)

translateVariables(
data = ICESDatsuscDataCopy,
TranslationDefinition = TranslationDefinition,
TranslationTable = TranslationTable,
VariableName = VariableName,
Conditional = Conditional,
ConditionalVariableNames = ConditionalVariableNames,
Translation = Translation,
PreserveClass = PreserveClass
)

return(ICESDatsuscDataCopy)
}



Expand Down
25 changes: 25 additions & 0 deletions R/Filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,28 @@ FilterICESDatras <- function(ICESDatrasData, FilterExpression = list()) {
return(ICESDatrasData)
}

#' Filter ICESDatsusc data
#'
#' Filters \code{\link{ICESDatsuscData}}.
#'
#' @param ICESDatsuscData Input \code{\link{ICESDatsuscData}} data.
#' @param FilterExpression Filter expression in list of strings. The name of the list and structures should be identical to the names of the input data list.
#'
#' @return An object of filtered data in the same format as the input data.
#'
#' @export
#'
FilterICESDatsusc <- function(ICESDatsuscData, FilterExpression = list()) {
# For filtering directly on the input data, we need to split the list filter expression to one level for the file and one for the table:
#FilterExpression <- expandFilterExpressionList(FilterExpression)

ICESDatsuscData <- filterData(
ICESDatsuscData,
filterExpression = FilterExpression,
propagateDownwards = TRUE,
propagateUpwards = FALSE
)

return(ICESDatsuscData)
}

58 changes: 31 additions & 27 deletions R/RstoxData-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,39 @@ utils::globalVariables(c(
"..colList", "..columns", "..groupingVariables", "..keep", "..parameterNames",
"..relevantColumns", "..replacement", "..sourceColumns", "..targetAndSourceVariables",
"..toKeep", "..valueVariablesInTranslation", "..varToExtract", "..variableKeys",
"..variablesInTable", "..x", "AcousticCategory", "Addition", "BeamKey", "CANoAtLngt",
"Channel", "ChannelDepthLower", "ChannelDepthUpper", "ChannelReferenceKey",
"ChannelReferenceType", "Constant", "Country", "Cruise", "CruiseKey", "DateTime", "DoorType",
"EDSU", "EchoType", "EffectiveTowDistance", "FishID", "Frequency", "Gear", "GearEx",
"HLNoAtLngt", "HaulNo", "ID", "LngtClass", "LngtCode", "LocalID", "LogKey", "N", "NewValue",
"NumberAtLength", "NumberOfIndividualsToGenerate", "NumberOfSampledIndividuals", "Quarter",
"ReplaceBy", "ResolutionCode", "SaCategory", "Scaling", "Ship", "SpecVal",
"SpeciesCategoryNumber", "SpeciesCategoryWeight", "SpeciesCode", "StatRec", "SubsampleWeight",
"SubsampledNumber", "Survey", "SweepLngt", "Time", "TransducerOrientation", "Value",
"VariableName", "WeightMeasurement", "acocat", "age", "agingstructure", "aphia",
"bottomdepthstart", "bottomdepthstop", "catCatchWgt", "catchcount", "catchpartnumber",
"..variablesInTable", "..x", "AcousticCategory", "Addition", "AphiaIDPredator", "AphiaIDPrey",
"BeamKey", "CANoAtLngt", "Channel", "ChannelDepthLower", "ChannelDepthUpper",
"ChannelReferenceKey", "ChannelReferenceType", "Constant", "Count", "Country", "Cruise",
"CruiseKey", "DateTime", "Day", "DigestionStage", "DoorType", "EDSU", "EchoType",
"EffectiveTowDistance", "FishID", "Frequency", "Gear", "GearEx", "GravMethod", "HLNoAtLngt",
"HaulNo", "ICESDatsucsData", "ID", "IdentMet", "LngtClass", "LngtCode", "LocalID", "LogKey",
"Month", "N", "NewValue", "Number", "NumberAtLength", "NumberOfIndividualsToGenerate",
"NumberOfSampledIndividuals", "PreySequence", "Quarter", "ReplaceBy", "ResolutionCode",
"SaCategory", "Scaling", "Ship", "SpecVal", "SpeciesCategoryNumber", "SpeciesCategoryWeight",
"SpeciesCode", "StatRec", "StationNumber", "StomachFullness", "SubFactor", "SubsampleWeight",
"SubsampledNumber", "Survey", "SweepLngt", "Time", "TotalCount", "TransducerOrientation",
"Value", "VariableName", "WeightMeasurement", "Year", "acocat", "age", "agingstructure",
"aphia", "bottomdepthstart", "bottomdepthstop", "catCatchWgt", "catchcount", "catchpartnumber",
"catchproducttype", "catchweight", "ch", "cruise", "currentReportingUnit", "direction",
"distance", "fishingdepthcount", "fishingdepthmax", "fishingdepthmin", "freq", "gear",
"gearflow", "inapplicableFormats", "individualweight", "integrator_dist", "iskey", "lat_start",
"lat_stop", "latitudeend", "latitudestart", "lengthCode", "lengthmeasurement",
"lengthresolution", "lengthsamplecount", "lengthsampleweight", "level", "liverweight",
"lngtClass", "lngtCode", "log_start", "logstart", "lon_start", "lon_stop", "longitudeend",
"longitudestart", "lsCountTot", "maturity", "maxFishID", "max_bot_depth", "meanW",
"missionstartdate", "missionstopdate", "nInd", "nation", "newClass", "newLngtCode",
"newLngtCodeNumeric", "newReportingUnit", "noMeas", "parasite", "pel_ch_thickness", "platform",
"platformname", "preferredagereading", "readability", "reportingUnit", "res", "sa",
"sampleFac", "serialnumber", "sex", "shortname", "specialstage", "specimenid", "start_time",
"startyear", "station", "stationstartdate", "stationstarttime", "stationstopdate",
"stationstoptime", "stomach", "stoxBioticObject", "subFactor", "subWeight", "suffixes",
"sum_sa.x", "sum_sa.y", "sweeplength", "tagid", "tagtype", "target", "threshold",
"tissuesample", "totalNo", "transceiver", "translationListOne", "trawldoorarea",
"trawldoorspread", "trawldoortype", "trawldoorweight", "variableToTranslate",
"verticaltrawlopening", "vesselspeed", "winddirection", "windspeed", "wingspread",
"wiredensity", "wirediameter", "wirelength", "xsdObjects"))
"gearflow", "i.replace_number", "inapplicableFormats", "individualweight", "integrator_dist",
"interval", "iskey", "lat_start", "lat_stop", "latitudeend", "latitudestart", "lengthCode",
"lengthintervalcount", "lengthintervalstart", "lengthmeasurement", "lengthresolution",
"lengthsamplecount", "lengthsampleweight", "level", "liverweight", "lngtClass", "lngtCode",
"log_start", "logstart", "lon_start", "lon_stop", "longitudeend", "longitudestart",
"lsCountTot", "maturity", "maxFishID", "max_bot_depth", "meanW", "missionstartdate",
"missionstopdate", "nInd", "nation", "newClass", "newLngtCode", "newLngtCodeNumeric",
"newReportingUnit", "noMeas", "parasite", "pel_ch_thickness", "platform", "platformname",
"preferredagereading", "preycategory", "preydigestion", "preyforeignobject", "preysampleid",
"readability", "reportingUnit", "res", "sa", "sampleFac", "serialnumber", "sex", "shortname",
"specialstage", "specimenid", "start_time", "startyear", "station", "stationstartdate",
"stationstarttime", "stationstopdate", "stationstoptime", "stomach", "stomachfillfield",
"stomachweight", "stoxBioticObject", "subFactor", "subWeight", "suffixes", "sum_sa.x",
"sum_sa.y", "sweeplength", "tagid", "tagtype", "target", "threshold", "tissuesample",
"totalNo", "totalweight", "transceiver", "translationListOne", "trawldoorarea",
"trawldoorspread", "trawldoortype", "trawldoorweight", "uniqueN", "variableToTranslate",
"verticaltrawlopening", "vesselspeed", "weightresolution", "winddirection", "windspeed",
"wingspread", "wiredensity", "wirediameter", "wirelength", "xsdObjects"))

.onLoad <- function(libname, pkgname) {
# Initiate the RstoxData environment:
Expand Down
Loading