Hi everybody, I have a question for you:
I need to make a pie chart with the % of the count of ID per each parameters (see the link of the Reprex: https://www.dropbox.com/s/ma5wqmegy6ud8q1/dataset%20example.csv?dl=0
I need to show in a pie chart data for the parameter Pr as follow:
for example, for the Pr = 1, I have 3000 id and I need to represent the % in a pie chart, respect to other values.
For the Pr = 2, I have 4500 id etc......
I have used pie() and also ggplot2 but they don't work...How can I do?
Thanks
That is not a reprex, that is a link to an unnecessarily large .csv file (please read the guide), here is a basic example of how to do a pie chart with ggplot2 and one of your variables.
You are using the count() function wrong, it doesn't take a vector as an argument, you have to pass a data frame and a variable name, like in the example I gave you before with your own data.
Perfect thanks
In order to insert also the % labels for each slide of the pie how can I do?
For each slide, I need the count of the ID for each program.
The percentage values have already been calculated in the percentage variable so you just have to add the labels to the plot, take a look at the geom_text() or geom_label() functions.
Have you read the documentation for the function? you are supposed to map the percentage variable to the label aesthetic inside an aes() function, so you are using the wrong syntax.