Adding Group Level information to individual users

Hello,
I have a data set that includes students within schools. Each student has demographic information. Initially there was in one Ethnicity variable, but I created separate binary variables for each Ethnic group. I want to store school-level totals within each individual student, so in addition to personal information, I can also see the number of students within the school, and the numbers of each ethnic group within that school.

I've tried using group_by, summarize, and tally within mutate, but maybe I'm not thinking about this the right way.

TLDR: How can I add group level demographic variables to individuals within each group?

It would help if you were to post a relevant piece of your data set, as well as the code you've tried.

Assuming you have two data frames, one with student data (including school name) and one with school data (including school name), this sounds like a job for a join function like left_join().

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.