Can someone please help with the subset function in R

It seems you have skipped the part of the code where you load the data, you can't subset something that doesn't exist so look for the instructions to load the required data set.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.