I have a big data frame df1
that has a column Student
which has string values for students name, Grades
with numeric values for the grades of an exam. Another data frame df2
that has three columns Class
numeric, From
To
as a range for the grade and Count
that summarizes how many students has a specific grade between some value for a specific class.
举个例子:
Stundent <- c("Mark", "Jhon", "Stuart", "Lillie", "Carl", "Jason", "Stewart","Jack")
Grades <- c(7,9,1,6,7,6,4,8)
df1 <- data.frame(Stundent,Grades)
Class <- c(101, 101, 201, 308, 507, 201, 507, 308)
from <- c(1,6,1,1,6,6,1,6)
to <- c(5,10,5,5,10,10,5,10)
Count <- c(0,2,1,0,1,1,1,2)
df2 <- data.frame(Class,from,to,Count)
df2 <- df2[order(df2$Class),]
我期望得到这样的东西
Students <- c("","Mark, Jhon", "Stuart", "Lillie", "","Carl, Jason", "Stewart", "Jack")
df3 <- data.frame(df2, Students)