yarrr
yarrr copied to clipboard
Why are Groups with 'NA'-Values dropped in pirateplot?
I have data that has no values for group B (all NA
). If I make a pirateplot, the group B is not plottet.
Group Year Value
1 A 2010 10
2 A 2015 15
3 B 2010 NA
4 B 2015 NA
5 C 2010 20
6 C 2015 25
Is there a possibility that I can include group B? In my case I want to show, that we got no results for group B. And I prefer keeping the values as NA
and not changing them to 0.
Here is a minimal example
dat <- data.frame(
Group = c('A', 'A', 'B', 'B', 'C', 'C'),
Year = rep(c('2010', '2015'), 3),
Value = c(10, 15, NA, NA, 20, 25)
)
yarrr::pirateplot(formula = Value ~ Year + Group, data = dat)
Hi! Not sure if it answers your question, but I believe that it is better that yarrr works this way. NA values are not equal to 0 (missing data could, in theory, take any possible value) and usually, we don't want them to be treated as 0's... So in your case if your NA's are actual 0's, I think it would be simpler to change them accordingly...
Cheers 😉
Ok - I see. So I tweak the plotting on my own like this.
- If all values of a group are
NA
, set one of them to themin
value of all other groups - plot a white polygon over the added faked values (here group B)
- add
NA
to the plot
As I mentioned before: I would like to show the fact, that we didn't get any data for group B, in our case this is an important fact that should not be dropped.
Thanks anyway!
@tinu-schneider Yes I see how visualising missing data could be important in some cases (though in others it might be a nuisance...). I'll work on adding a new logical argument called ignore.missing
that controls this.
Sounds good!