Closed edvinf closed 1 year ago
This should be tested in latest master on GitHub.
Tested on master. Works now.
There are still cases where this error occurs. Specifically it seems to happen when there are prey-samples in the data.
The following example and data file reproduces the issue, and removing the prey-element from the data file makes it go away.
library(RstoxData) bio <- RstoxData::ReadBiotic(c("biotic3.1_w_ageandprey.xml"))
filterSample <- list() filterSample$biotic3.1_w_ageandprey.xml$fishstation <- c( paste("serialnumber == '", 2, "'", sep="") ) sampledata <- RstoxData::FilterBiotic(bio, filterSample)
print(nrow(sampledata$biotic3.1_w_ageandprey.xml$individual))
print(nrow(sampledata$biotic3.1_w_ageandprey.xml$agedetermination))
A possible soultion has been drafted in https://github.com/StoXProject/RstoxData/commits/propogateFilterBug
filtering on raw landings (LandingData) should also be a test case, as it also has parallell levels in the hierarchy, and we have some indication that the current filtering does not work (does not apply to aggreagted landings (StoxLandingData))
FilterBiotic does not propagate filters lower than individual level. That is agedetermination rows are kept even if the corresponding individual is removed.
partial example: filterSample <- list() filterSample$
samples2021.xml
$catchsample <- c( paste("catchsampleid == '", stationdata$samples2021.xml$catchsample$catchsampleid[i], "'", sep="") ) sampledata <- RstoxData::FilterBiotic(stationdata, filterSample)nrow(sampledata$samples2021.xml$individual) 10 nrow(sampledata$samples2021.xml$agedetermination) 96689
No agedeterminations are expected for this example:
sampledata$samples2021.xml$catchsample$agingstructure NA
nrow(merge(sampledata$samples2021.xml$individual, sampledata$samples2021.xml$agedetermination)) 0