0

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")

1 Answers1

0

Does Ge19WdSt refer to anything?

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


chris jude
  • 467
  • 3
  • 8