Making excel sheets according to unique id.

Hi. I have a data with teacher ID, student name and their marks. I want to convert this into excel sheets in such a way that in a single workbook, different sheets are created for each instructor ID. Is this possible?

library(tidyverse)

nithin<-tibble::tribble(
  ~instructor.ID,   ~student, ~marks,
        "INS001",   "Nithin",    41L,
        "INS001",  "Vinayak",    45L,
        "INS001",   "Freddy",    48L,
        "INS001",   "Brinda",    39L,
        "INS002",  "Pradeep",    33L,
        "INS002",  "Sunitha",    45L,
        "INS002",    "Madhu",    30L,
        "INS002",   "Vittal",    50L,
        "INS002",  "Cherene",    50L,
        "INS003",    "Karen",    28L,
        "INS003",    "Kunal",    45L,
        "INS003",    "Patel",    35L,
        "INS003",    "Nehru",    40L,
        "INS003",   "Rajaji",    39L,
        "INS003",   "Girish",    32L,
        "INS003", "Gayathri",    32L
  )
Created on 2022-03-08 by the reprex package (v2.0.1)

Have a look at https://forum.posit.co/t/creating-a-list-of-data-frames-and-then-assigning-group-names/130882 and the link I gave in that thread.

Try this:

split(nithin, f = nithin$instructor.ID) %>% 
  writexl::write_xlsx(., "teacher-student.xlsx")

Thanks a lot. This is exactly what i was looking for.

This topic was automatically closed 7 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.