Query related to R language to find percentage

Hello all,

I have one query, could u please help me to solve the below question. I am not getting any idea how to solve it.

Q. Analyse the department wise turnouts and find out the percentage of employees leaving from each department?

Please find the data set in the attached image.

A reproducible example, called a reprex would provide a more detailed answer.

Let's take this is pieces.

  1. I assume your data structure is a data frame or a tibble and that rows represent individual employees.
  2. You have classified each employee's start date and end date into a period such as a month or quarter.
  3. You can calculate the number of employees in each department during any time in the quarter by using group_by() and summarize(). See the dplyr page. That's your denominator.
  4. You can similarly calculate the number of employees left standing at the end of the quarter. That your numerator.
> library(scales)
> numerator <- 324
> denominator <- 412
> turnover <- numerator/denominator # as a proportion
> turnover
[1] 0.7864078
> turnover_unformat <- turnover*100
> turnover_unformat
[1] 78.64078
> turnover_pct <- percent(turnover, accuracy = 0.01) # as a percentage to two places
> turnover_pct
[1] "78.64%"
2 Likes

Thanks Richard !!!!!!!!!!!!!!

I will check and get back to you .

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