GGPLOT2 bar chart

hi, i have this problem where i need to plot a bar chart for a certain number of variable, but i need 3 grouping bars represent 3 different information for each variable for comparing all of them in one chart.
i was wondering is it possible to do so i can only have 1 bar, this is what i've got so far and it only show bar graph of the 1st variable being x and the 2nd one, i'm trying to show all the other 3 on for each of the 'company' but dont know how:

library(ggplot2)
library(dplyr)
library(tidyverse)
information <- data.frame(company = c('Instagram', 'Netflix', 'Youtube', 'Amazon', 'Facebook',
'Linkedin', 'Twitter', 'Uber', 'Tinder', 'Zoom', 'Apple', 'Tiktok', 'Spotify', 'Microsoft'),
word_count = c(2451, 2628, 3308, 3416, 4132, 4346, 5633, 5658,
6215, 7243, 7314, 7459, 8600, 15260),
Readtime= c(10.21,10.95,13.78,14.23,17.22,18.11,23.47,23.58,25.9,
30.18,30.48,31.08,35.83,63.58),
readingscore= c(54,45,50,45,56,54,39,40,46,42,47,44,44,54))

ggplot(information, aes(x = company, y = word_count)) +
geom_bar(stat = "identity", position = 'dodge')

thanks

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

hi, thank you i have already edit it and add in what i have so far, i'd appreciate your reply and also it'd be great if you can have a look and maybe have some idea on how i can solve this problem thanks a lot

I think this is what you mean but the scale differences among variables makes the plot hard to read

library(tidyverse)

information <- data.frame(company = c('Instagram', 'Netflix', 'Youtube', 'Amazon', 'Facebook',
                                      'Linkedin', 'Twitter', 'Uber', 'Tinder', 'Zoom', 'Apple', 'Tiktok', 'Spotify', 'Microsoft'),
                          word_count = c(2451, 2628, 3308, 3416, 4132, 4346, 5633, 5658,
                                         6215, 7243, 7314, 7459, 8600, 15260),
                          Readtime= c(10.21,10.95,13.78,14.23,17.22,18.11,23.47,23.58,25.9,
                                      30.18,30.48,31.08,35.83,63.58),
                          readingscore= c(54,45,50,45,56,54,39,40,46,42,47,44,44,54))

information %>% 
    gather(metric, value, -company) %>% 
    ggplot(aes(x = company, y = value, fill = metric)) +
    geom_col() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))

Created on 2021-05-04 by the reprex package (v2.0.0)

Maybe consider faceting the plot

information %>% 
    gather(metric, value, -company) %>% 
    ggplot(aes(x = company, y = value, fill = metric)) +
    geom_col() +
    facet_wrap("metric", scales = "free_y", ncol = 1) +
    theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.