Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on "count column is missing in your data" #7

Open
wook2014 opened this issue Jul 28, 2023 · 2 comments
Open

Error on "count column is missing in your data" #7

wook2014 opened this issue Jul 28, 2023 · 2 comments

Comments

@wook2014
Copy link

wook2014 commented Jul 28, 2023

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 numbertocount? 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.

@wook2014
Copy link
Author

wook2014 commented Jul 28, 2023

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.

@showteeth
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants