I used an lapply function twice to analyse the data of passed students and failed students of 30 schools across class1-5. Using a Split function two dataframes has been split based on school names. Now, I need to see passed students and failed students of a school(school-wise) list in a single file.
Here's my code:
spt1 <-split(pass, pass$school)
# ^ result1 is a dataframe, splitting school wise in pass df
abc=lapply(names(spt1), function(x){write.table(spt1[[x]],
file = paste("C:/Users/Documents/Output/Pass", x, ".csv"), row.names = FALSE ,sep = "," )})
# ^ for loop to seggregate passed list across all schools
spt2 <-split(fail, fail$school)
# ^ splitting failur list in the dataframe based on schools
def=lapply(names(spt2), function(x){write.table(spt2[[x]],
file = paste("C:/Users/Documents/Output/Fail", x, ".csv"), row.names = FALSE , sep = ",",)})
# ^ for loop to seggregate failure list across all schools
Now, I would like to see the data of passed and failure students of a school in a single pdf or csv. The expected output would be 30pdf for 30schools that each pdf contains list of passed and failed students
Note: Columns are different for all the files across two folders.