Hello all,
I am in need of some emergency help. I am working on an assignment that is due tuesday, i am 30 hrs deep and i have a few problems.
One of my smaller problems but bigger ones is I have these 2 loops, and I want to store the outputs into a data dataframe, but when I run it only the last entry is being stored and none of the others.
Any help would be greatly appreciated.
class_roster <- data.frame(read.csv("class_roster.csv"))
print(class_roster)
class_roster <- tibble::rowid_to_column(class_roster,"Student_ID")
class_roster <- class_roster %>% unite('Full_Name', First.Name:Last.Name, remove = FALSE)
numbers_used_Q3 <- 1:nrow(class_roster)
print(class_roster)
print(numbers_used_Q3)
student_marking <- vector() #who is marking
#students_used <- vector() #people being marked by Student_marking
NQ3 <- 33
final_list <- data.frame()
if(NQ3 < 4)
{
print("This roster size is too small. Minimum of 4")
}else
{
###################################################################
#Go over the whole class list
#for (i in 1:NQ3)
for (i in 1: 6){
#Get the student who is going to be the marker
if(i <= 6) #NQ3
{
temp_list <- c()
#Make sure no duplicate student markers are used
while (TRUE) {
rng_Q3 <- sample(numbers_used_Q3, 1) #pick a student to be the marker
print(paste("Student who is marking is " , rng_Q3))
if(!rng_Q3 %in% student_marking) #check for previously used student markers
{
break
}#end IF
} #end while
student_marking <- append(student_marking, rng_Q3) #This stores the list of students already picked to be markers
################################################
students_used <- vector()
for (i in 1:3)
{
while (TRUE)
{
rng_Q3_1 <- sample(numbers_used_Q3, 1)
print(paste("Students projects to be graded ", rng_Q3_1))
if(rng_Q3_1 != rng_Q3) #make sure the project being picked is the markers project
{
break
#end IF
}
if(!rng_Q3_1 %in% students_used) #check to make sure the same student project isnt being picked twice for the marker
{
break
} #end IF
temp_list <- c(temp_list, rng_Q3, rng_Q3_1)
print("temp list")
print(temp_list)
}#END WHILE
students_used <- append(students_used, rng_Q3_1)
} #END FOR LOOP 1:3
} #end IF
} #End For
}#end Else