% in barplot() instead of count [duplicate] - r

This question already has answers here:
How can I change the Y-axis figures into percentages in a barplot?
(4 answers)
Closed 8 years ago.
I did a script to have a good barplot with barplot() on R
Is it possible to have on the y-axis the % and not the quantity (number of observations) ?
I would love to have the % without to change all of the script...
Thanks a lot

ggplot has this option, but for barplot() I believe you will have to make a new variable that represents the percent and then feed that into barplot()

Related

Expanding the X-axis using R [duplicate]

This question already has answers here:
How do I show all boxplot labels
(3 answers)
How to save a plot as image on the disk?
(11 answers)
Closed 2 years ago.
there has some issue with my axis, I want to show the full data at the axis but I am not sure how to expand it. This my code.
boxplot(Complied_Data$`Stress (N/m2)` ~ Complied_Data$Category,
main="Stress Distribution of different rates", ylab="Stress (Pa)",
xlab="Specimens", notch=TRUE, col="brown1", cex=10)

R remove names and order ggplot by frequency [duplicate]

This question already has answers here:
Order Bars in ggplot2 bar graph
(16 answers)
Remove all of x axis labels in ggplot [duplicate]
(1 answer)
Closed 2 years ago.
I have a dataframe DiatomFiltered containing the column species. I want to have a ggplot (ggplot2) of all species and their frequency ordered from highest to lowest. The below code works, but the names are a mess (because of way too many species names) so I want to remove that and i want the frequencies ordered. How do i do this?
ggplot(DiatomFiltered, aes(species)) +
geom_bar(fill = "#0073C2FF")

Break or kink // in x axis in ggplot2 [duplicate]

This question already has answers here:
Using ggplot2, can I insert a break in the axis?
(10 answers)
Put a break in the Y-Axis of a histogram
(2 answers)
Closed 2 years ago.
ggplot(data= data,aes=(x=parameter,y= Count,fill=value)) + geom_bar(position="dodge",stat="identity")+ cord_flip()
I want to get break in x-axis like initially, I want scales to be 1,2,3,4,5 then a break followed by 5,10,15. Please refer the below figure for break or kink I am talking about

R: How to make the x and y axis be the same length? [duplicate]

This question already has answers here:
How to define fixed aspect-ratio for (base R) scatter-plot
(2 answers)
Closed 7 years ago.
R always makes x axis longer compared to the y axis, even if they both have the same limits. Is there an option to control the length of the axis?
plot(0:100,0:100)
I need it to be a square.
Yes, at least if you are using base graphics. The asp argument should be set to 1:
plot(0:100,0:100, asp=1) # see ?plot.default
The duplicate that Ben found also has
plot(0:100,0:100, pty="s")

How do I display only selected items in a ggplot2 legend? [duplicate]

This question already has an answer here:
Remove legend entries for some factors levels
(1 answer)
Closed 7 years ago.
I'm creating a stacked bar plot of relative abundance data, but I only want to display the ten most abundant organisms in the legend. How do I do this? I have no idea where to begin and haven't found any answers online.
Here's the plot with a full legend:
Thanks.
As pointed out by user20650 in the comments, the answer is to add a list of selected items to the breaks= argument in scale_fill_manual()
scale_fill_manual(breaks=list,values=colpal)

Resources