Home > Software design >  How can I resolve this error and generate a bar chart?: Error in check_aesthetics(evaled, n)
How can I resolve this error and generate a bar chart?: Error in check_aesthetics(evaled, n)

Time:12-15

I'm familiarizing myself with tidyverse. Able to produce a barchart with the default barchart(), but I'm running into issues with this. All objects are of equal length and I'm not sure what exact mistake I'm making within aoe(). Thank you in advance.

### Sample data
    df <- data.frame(a = c(sample(500:2000,50)),
                     b = c(sample(500:2000,50)),
                     c = c(sample(500:2000,50)),
                     d = c(sample(500:2000,50)),
                     e = c(sample(500:2000,50)),
                     f = c(sample(500:2000,50)),
                     g = c(sample(500:2000,50)),
                     h = c(sample(500:2000,50)),
                     i = c(sample(500:2000,50)),
                     j = c(sample(500:2000,50)),
                     k = c(sample(500:2000,50)),
                     l = c(sample(500:2000,50)),
                     m = c(sample(500:2000,50)),
                     n = c(sample(500:2000,50)))
    
### Assign values to objects    
    totals <- apply(df, 2, sum)
    names <- c(colnames(df))
### Create bar chart    
    ggplot(df, aes(x = names, y = totals))   geom_bar(stat = "identity")

CodePudding user response:

Does Ge19WdSt refer to anything?

library(ggplot2)
ggplot(cbind.data.frame(names,totals),aes(x = names, y = totals))   geom_bar(stat = "identity")


  • Related