Hi,
I have a dataset with school names and teachers as in the dataframe "data". I need to create a new variable by which the first teacher of the first school is called "Class 1" and second teacher is called "Class 2". This system then proceeds for all schools as shown in the dataframe "data1".
How can I do this?
library(tidyverse)
data<-tibble::tribble(
~school_name, ~teacher_name,
"GHPS UNKAL", "Nithin",
"GHPS UNKAL", "Naveen",
"GHPS BYAHATTI", "Bindu",
"GHPS SHIVALLI", "Julia",
"GHPS REVADIHAL", "Nutan",
"GHPS REVADIHAL", "Zidan"
)
data1<-tibble::tribble(
~school_name, ~teacher_name, ~class_number,
"GHPS UNKAL", "Nithin", "Class 1",
"GHPS UNKAL", "Naveen", "Class 2",
"GHPS BYAHATTI", "Bindu", "Class 1",
"GHPS SHIVALLI", "Julia", "Class 1",
"GHPS REVADIHAL", "Nutan", "Class 1",
"GHPS REVADIHAL", "Zidan", "Class 2"
)
Created on 2022-07-22 by the reprex package (v2.0.1)