I need 30 students to form a group to find out the best group size in their project work.
the principle forming a group is the last group size lower than by one, the number of groups = the total count
for example 30 students:
7+6+5+4+3+2+1 = 28, here the total number is not equal 30 , here, we ignore 2 students since 2 students are not sufficient to form a group.
The total number of groups is 7
how we can make this in a while loop, could you share your knowledge?
the result shows like this if students = 30
print(group_total)
[1] 36
print(group_size)
[1]
print(n_groups)
[1] 7
however, the result should look like this
print(group_total)
[1] 28
I have a bias against control structures, such as while because from a user-facing perspective R presents as a functional language—f(x)=y. It's almost always better to specify what is desired than how, if for no other reason than that it forces clarification of exactly the outcome being sought.
But, yes, these functions can be used in a loop, but what does that get you that this doesn't?