joachim-gassen / tidycovid19

{tidycovid19}: An R Package to Download, Tidy and Visualize Covid-19 Related Data
https://joachim-gassen.github.io/tidycovid19/
Other
146 stars 44 forks source link

Force comparisons to be booleans to avoid "'i' must have one dimensio… #17

Closed awchisholm closed 2 years ago

awchisholm commented 4 years ago

Calls to function plot_covid19_stripes cause error "'i' must have one dimension, not 2." if diverging_color_scale is set to FALSE. This seems to be because the comparisons on line 128 in this file return a data frame rather than booleans.

joachim-gassen commented 4 years ago

Hi there! Thank you for the bug report and the PR. I am trying to reproduce the error that you mention but cannot generate it using standard data.

df[, type] <= 0 should return a data frame/tibble of booleans of dimension 1 if type is of length 1. I would like to understand exactly what the problem is to rule out that you hit on an error that has consequences elsewhere in the code.

Thanks!

awchisholm commented 4 years ago

Hello, I got the error by running the example for plot_covid19_strip

merged <- download_merged_data(cached = TRUE, silent = TRUE) plot_covid19_stripes(merged, per_capita = TRUE, population_cutoff = 10)

and I agree that it should work as you say.

I tried again on another machine and needless to say the problem disappeared. I'm not sure what is different about the machine where it doesn't work. I suggest I'll keep my eye on it and if it does happen again I'll take more care to make it reproducible.

joachim-gassen commented 4 years ago

Sounds very good. Thanks!

amayomode commented 4 years ago

I had the same error but I realized that the problem was that I was using an old version of tibble. As soon as I updated it, then the error disappeared.