1

I have the following data

data <- data.frame(Month = c("Sep", "Oct", "Nov"),
                   Year = c(2021,2021,2021),
                   Active = c(20,15,29),
                   Inactive = c(40,32,20))

enter image description here

The columns "active" and "inactive" are counts but since I'm trying to make some graphs it's difficult to work with. My desired output would be to combine the columns into a new one that shows the following. "Status" would be the new column created.

enter image description here

RL_Pug
  • 697
  • 7
  • 30

1 Answers1

1

Here you go:

library(tidyverse)
data %>% pivot_longer(cols = c(Active, Inactive), names_to = "Status", values_to = "Count")  %>% arrange(Status)

Bloxx
  • 1,495
  • 1
  • 9
  • 21