ggpie
ggpie copied to clipboard
Error on "count column is missing in your data"
Appreciate for creating such a good package. I meet up with a problem when using ggpie with summarized data. I have my data like this:
dt <- data.frame(
Name = c("A", "B", "C","D","E"),
number = c(40, 35, 30,25,20)
)
and this is a summarized data. According to the document mentioned in https://showteeth.github.io/ggpie/reference/ggpie.html
it seemed that I can directly use number
as the proportion for the pie chart by setting count_type = "count"
, but it is confused that how to assign the count
column and after I run my code like this:
ggdonut(data = dt, group_key = "Name", count_type = "count",
label_info = c("all"), label_type = "horizon",
label_size = 4, label_pos = "out", label_threshold = 15)
an error occurs:
Error in PrepareData(data = data, group_key = group_key, count_type = count_type, : count column is missing in your data.
How to solve the problem? Should I rename the column number
tocount
? And I suggest that there should be some examples with count_type = "count"
in the readme document to show how to deal with wide data instead of long data.
I checked the code in utils.R
and it seemed that I really need to rename the summarized data column to count
. It could be better for users to assign their data column by custom.
Thanks for your advice! I noticed you used label_info = c("all")
, this is not the latest usage. To increase flexibility, ggpie enables users to combine different label information ("group", "count", "ratio"):
# install the lastest version
remotes::install_github("showteeth/ggpie")
library(ggpie)
dt <- data.frame(
Name = c("A", "B", "C","D","E"),
count = c(40, 35, 30,25,20)
)
ggdonut(data = dt, group_key = "Name", count_type = "count",
label_info = c("count"), label_type = "horizon",
label_size = 4, label_pos = "out", label_threshold = 15)
Please let me know if you need any help. YB