I tried to plot a barchart with 3 groups (Tentative, Certain, Ratio) of data.
Assumption: 14 colors are too many for the standard ggplot to "come up with itself"
Question1: How do i get the plot working?
(optional) Question2: How do i get the bars for each group to sort ascending?
The Errors are:
- Error: Aesthetics must be either length 1 or the same as the data (14): y
- Error: Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?
my data.frame (14 obs, 4 Variables, 3 Numeric, 1 Character)
tibble::tribble(
~Nachname, ~Tentative, ~Certain, ~Ratio,
"abc", 195, 516, 321,
"def", 140, 483, 343,
"dgh", 92, 512, 420,
"dfh", 56, 262, 206,
"zit", 93, 368, 275,
"fxg", 67, 464, 397,
"awr", 143, 582, 439,
"nvg", 98, 448, 350,
"uipi", 209, 666, 457,
"lzu", 155, 487, 332,
"awe", 115, 398, 283,
"sdg", 222, 670, 448,
"cvb", 124, 539, 415,
"mjk", 158, 406, 248
my (error) code
nb.cols = 14
mycolors = colorRampPalette(brewer.pal(8, "Set2"))(nb.cols)
> ggplot(liwc_Nachname, aes(x = liwc_Nachname$Nachname, y = c(liwc_Nachname$Certain, liwc_Nachname$Tentative, liwc_Nachname$Ratio)))
Error: Aesthetics must be either length 1 or the same as the data (14): y
> geom_col(position = position_dodge()) +
+ scale_fill_manual(values = mycolors)
Error: Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?
Appreciative of any help. Thanks