Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201941

How to plot a bar chart for selected observations in R studio [closed]

$
0
0

I am trying to produce a bar chart for the average number of employees in different companies where the year should be before 2000. I have data on the number of employees for each company between the period 2000 and 2015.

I tried the following code

library(tidyverse)

Employment_data <- data.frame(
    Company = sample(letters[1:5], 100, replace = T),
    year_group= sample(x = c('before_2000', "after_2000"), 100, replace = T),
    Number_employee = rpois(n = 100, lambda = 250)
)

Em_plot <- Employment_data %>%
    group_by(Company)%>% [$year_group=='before_2000']) %>%
    summarise(mean_employee=mean(Number_employee,na.rm=TRUE)) %>% 
    (barplot(Em_plot$mean_employee,main="Average number of employee by company", horiz=FALSE, names.arg = Employee_plot$Age))

But I failed to manage it. Any help is appreciated.


Viewing all articles
Browse latest Browse all 201941

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>