Length-based FLQuant converted to age-based when creating FLStock
marchtaylor opened this issue · 4 comments
Hello,
When converting a length-based FLQuant to an FLStock, the 1st dimension name is converted back to age, and I am unable to change this. I may be wrong, but I think this was not happening in earlier versions of FLCore.
Ex.:
flq.l <- FLCore::FLQuant(
NaN, quant = "length",
dim = c(10, 20, 1, 1, 1, 1),
dimnames = list(length = ac(seq(10)), year = ac(seq(20)), unit = "unique",
season = "all", area = "unique", iter = "1")
)
dimnames(flq.l)
stock.l <- FLCore::FLStock(flq.l)
dimnames(stock.l) # 1st dimantion is no longer "length"
names(dimnames(stock.l))[1] <- "length" # unable to update (in this way)
# Error in (function (classes, fdef, mtable) :
# unable to find an inherited method for function ‘range<-’ for signature ‘"FLStock", "missing", "character"’
The FLStockLen has been in FLCore for quite some time, but I cannot say for certain when did we start forcing 'age' to be the first dimension in FLStock.
stock.l <- FLCore::FLStockLen(flq.l)
names(stock.l)
Only some basic methods exist for it, but we can extend it as needed.
There are also a few fairly recent methods for length data in length.R.
Thanks Iago,
I think I will just stick with the typical FLStock object for now, as I'm only using it as a place to store information for the moment.
Cheers,
Marc
I am afraid quite a few methods for FLStock assume, rightly or wrongly, that quant
is age
, so I would prefer not to relax that assumption in the constructor. It could maybe check if quant='len'
and then call FLStockLen for you. Would that work?
It's OK to use FLStock at the moment - I just need to review my code and make sure I do not make any calls to a dimension called "length". So far, this is working for me.