afsc-assessments / osa_resid

0 stars 0 forks source link

ggplot for osa and pearson comparison mislabeled in plot_osa_comps? #2

Open careymcg opened 1 month ago

careymcg commented 1 month ago

On line 43 of plot_osa_comps the ggplot says:

g1 <- ggplot(reslong, aes(year, index, size=abs(resid), color=resid>0)) + geom_point() + ggtitle(paste0('OSA w/o ', index_label, ' 1')) + ylim(range(index)) + ylab(index_label)

where the index dropped from the OSAs is hard-wired to be 1. However, it looks to me like compResidual::resMulti automatically drops the last index. Later in the code when it loops over which index is dropped it accomplishes this through these two lines, which seem to be missing in the calculations leading to the ggplot on line 43:

index2 <- index[-ind] o2 <- cbind(o[,-ind], o[,ind]) p2 <- cbind(p[,-ind], p[,ind]) res <- resMulti(t(o2), t(p2))

Sorry if I am mistaken or missing something here!

Cole-Monnahan-NOAA commented 1 month ago

resMulti indeed drops the last bin. So the code you linked puts the desired index into the last bin so that it's dropped. I think your concern is that the label will be wrong? If so then yes that's a bug. Can you confirm? 1 should be replaced with ind I think.

careymcg commented 1 month ago

On line 43 the code is not looping over "ind." So I think the label should just say that the last bin was dropped, yes?

Cole-Monnahan-NOAA commented 1 month ago

I think you're talking about the title where it's supposed to print the index (age or length bin) that is dropped. So yes that's wrong and should be ggtitle(paste('OSA w/o', index_label, ind)). There's no looping over bins b/c the resMulti function does that internally and returns a vector of ages.