random group generator in R - random

I have a data set consisting of 250 students from different schools and classrooms. For the experimental design, I would like to generate in a random manner 35 groups consisting of approx. 7 students in each group, and then after the first activity, break up the students as randomly as possible in to 25 groups of 10 students each. Is there a package and example of how I can perform this in R?

If there's no relation between which groups students are in during the first and second activities, then it's the same problem twice over.
Assuming a student can only belong to one group at a time, just shuffle the array and pull out elements per your group size until there are no more left.
students=1:250;
rand_students=sample(students,length(students));

Related

Student-group allocation algorithm

I have 150 students, and have to assign them to specific groups (with different topics). They can rank their preferences for the topics and will each have different groups. My main issue (more than being optimal with respect to a certain metric) is that the outcome has to be doable in the timetable.
More precisely, here are some data:
150 students
10 topics that each student will rank
each student will be assigned to 5 topics
the groups for each topic have to be between 10 and 15 (there may be various groups for the same topic or no group for some topics)
the final assignment has to fit into a timetable: there will be only 5 time slots (different groups can be on the same slots, but students cannot duplicate themselves to follow various groups at the same time)
What kind of algorithms could provide possibilities for such a situation?

Creating a matchmaking algorithm with two different groups

Lets say that there is a queue where users await matchmaking. The algorithm needs to select a number of hosts from two different groups (group A and group B). The players of each match will be part of the opposite group from the host (match hosted by a member of group A will be filled with players from group B). However, the queue will most likely have a disproportionate ratio of these groups. For example, group A could have 100 people in queue and group B could have 300. Games will be generated with between 5-10 players for each host.
What is a good way to go about this that minimizes the amount of people not in a match and evenly disperses hosting roles between the two groups?

Process to most efficiently fill 6 rows of 21 seats with various group sizes

I have 6 rows of 21 chairs in a building and a booking system where groups of different sizes can book in, with 2 chairs required between each group for social distancing purposes. We want to fit as many people as possible but maintain fairness so smaller groups booking later don't usurp larger groups who already booked earlier. They don't have to be seated in chronological order. Lastly, whilst an attempted booking of more than one person might get rightfully rejected because there's no space to accommodate them, a single booking made after CAN be accepted if they do fit.
I have almost achieved all the above, but not quite... This is how my process works (I could add a lot of code here, but I'm not really after code, rather I need the explanation of what to change that I can't quite grasp. I hope that's ok):
Order the bookings so far chronologically
Loop through each row starting with 21
for each booking, check if the group size + 2 fit. If they do, add them to that rows array, remove them from the bookings array and reduce the number of seats remaining by the group size + 2. Do this until no remaining bookings will fit on this row.
If the remaining seats is 0 then there will be 2 unnecessary 'buffer' seats at the end of the row, but not even a group size of 1 will fit with 2 sets between them and the previous group, so ignore this fact and move on.
If the remaining seats is more than 0 then go through the remaining bookings AGAIN and see if any of the groups will fit WITHOUT adding the 2 seats buffer. If they do, add them to the row array, remove them from the bookings array and break the loop and move onto the next row.
Hopefully you can follow my logic there. It works really well but it isn't filling up the rows in the most efficient way. The bookings don't need to be sat in chronological order but we can't have previous booked in bookings being pushed out by smaller, more recent bookings because they are fitting as efficiently.
Does anyone have any light to shed? My brain is melting!
Since adding small groups is easier than adding large groups, you should place the large groups first.
Suppose the situation is this: you currently have a list of groups that fit. Suddenly, a new group G attempts to book. Try to fit the new group by sorting all the groups by size and placing the groups largest first, smallest last. If this work, accept the new booking of G with the new placement. But if this results in an earlier group no longer fitting, then reject the new group G and keep the old placement.
When you reject a group because you can't fit it, you can also keep the size of that group in memory; the next time a group of equal size or larger attempts to book, you can immediately reject them because you know that you can't fit this size.

List of users with the highest sum of points

I would like to create a ranking ordered by the user who has the most "points" scored.
My "points" table has these fields: user_id, type and quantity.
In this example, user 1 has a total of 4 points, while user 2 has a total of 8.
My dilemma after several unsuccessful tests, is to create a cycle that shows users with the highest sum of "quantity".
How can I do?
you need to use selectRaw(sum(columan) as total) then group
Point::selectRaw("SUM(quantity) as total_quantity,user_id")->groupBy('user_id')->get()

Counting values generated by a Matrix in SSRS

I have created a matrix report that has a Row Group of Person and a column group of Subject with Child groups of SubmittedBy and Grading Name. The data that is being pulled through is a mixture of numerical and alphabetic data. I am needing to do a count per row of how many of a certain criteria appear. For example, I wish to count by person how many 1's they have achieved, or how many A* they have achieved (this is all grading data from a school). Is there a way to do this with matrix data?
If there is a way, can you then get a count using certain criteria, for example, if grading Name = focus count how many WB grades there are per person (row)?
This is the Design
This shows a subsection of data (as it is a very large dataset), but with SchoolID, Forename and Surname cut off to preserve anonymity.
A simple way would be to add Total to the Subject row group and use the count() function:
[

Resources