ggplot2 - Convert the labels in %.

0 votes
I have created a bar chart using ggplot2 in R. Now i want to change the labels in the plot to %. How to acheive this?
Aug 1 in Data Analytics by koyila
15 views

1 answer to this question.

0 votes

Use geom_label or geom_text and provide labels like below.

> ggplot(mpg,aes(cyl))+geom_bar(stat = "count")+geom_label(aes(cyl,85,label=paste(cyl,"cyl",sep = " ")))

In your case, update paste fucnction with paste([field/variable], "%", sep = " ")

I hope this will do.

answered Oct 30 by Cherukuri
• 31,840 points

Related Questions In Data Analytics

0 votes
1 answer

How can I add x and y axis labels in ggplot2 ?

# Load a dataset(to work with) # We’ll ...READ MORE

answered May 16, 2018 in Data Analytics by zombie
• 3,690 points
135 views
0 votes
1 answer

% of nulls for each column in the dataset - R

Use code as below -  lapply(air,function(x) { length(which(is. ...READ MORE

answered Jul 4 in Data Analytics by anonymous
• 31,840 points
36 views
0 votes
1 answer

plot a line chart along with point labels in the plot

Follow the below steps: 1. Create a ggplot ...READ MORE

answered Nov 2 in Data Analytics by anonymous
• 31,840 points
21 views
0 votes
1 answer

Splunk Cluster instalation document was not uploaded in the cource.

Dear Learner, Greetings ! We would like to inform ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
62 views
0 votes
1 answer

How to plot side-by-side Plots with ggplot2 in R?

By Using gridExtra library we can easily ...READ MORE

answered Apr 16, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,721 views
0 votes
1 answer

Aligning title in ggplot2

You can use the theme layer to ...READ MORE

answered Apr 27, 2018 in Data Analytics by Bharani
• 4,550 points
816 views
0 votes
1 answer

Changing the order of bars in a bar-plot - ggplot2 - R

You can use the scale_x_discrete() function with ...READ MORE

answered May 28, 2018 in Data Analytics by Bharani
• 4,550 points
3,442 views
0 votes
1 answer

Showing percentage instead of counts in a bar plot - ggplot2 - R

Load the 'scales' package first, which gives ...READ MORE

answered May 28, 2018 in Data Analytics by Bharani
• 4,550 points
1,439 views
0 votes
2 answers

What is the difference between %% and % in R programming?

HI, %% returns remainder in case of numeric ...READ MORE

answered Aug 26 in Data Analytics by anonymous
• 31,840 points
86 views
0 votes
2 answers

Change the default order of labels of factor in R

You can also use relevel() to change ...READ MORE

answered Jun 27 in Data Analytics by sindhu
41 views