I am looking to plot just the percent of measurements that fall within bands. I have them separated into low med and high. But when I plot them, it will show not show values representatively (See image for example output)
Code Below
percents <- data.frame(TI = c("Low","Med","High"),
percent = c(format((totallowcount/totalvaluescount)*100,digits=3),
format((totalmedcount/totalvaluescount)*100,digits=3),
format((totalhighcount/totalvaluescount)*100,digits=3)))
TIbarplot <- ggplot(data = percents, aes(x = TI, y = percent)) +
geom_bar(stat = 'identity') +
scale_x_discrete(limits = c("Low","Med","High"))
I looked into doing scale_y_discrete scale_y_discrete(limits=c(0,25,50,100))
but kept getting errors for it.
Error in matrix(value, n, p) :
'data' must be of a vector type, was 'NULL'
In addition: Warning message:
Removed 3 rows containing missing values
(position_stack).
format
is converting your values into strings. For example, runclass(format(1.1234, digits = 1))
. The data frame then calls them factors. If you want to round to three digits, useround
instead offormat
. – Lyngbakr Feb 22 at 19:29