Problem with getting the difference between two numbers within a group, for all groups in the dataset

Hello!

Before I will state my problem I will have to apologize for my bad use of English as well as my limited experience with R.

So I have the following problem;
I have a dataset, with two test scores of students in different schools within different municipalities. I want to get the difference between these two test scores for each school in each municipality. As my data has a large number of observations I cannot be asked to do this manually. All help is appreciated!

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Hello!

Thank you for the advice. I will see what I can do!