Could you explain how the answer came about?

Your first stop should be your professor or fellow students. Make sure you read the home work policy:

As far as I can tell, you cannot know exactly what table(x) will give you since the sample command is random. If you want the same numbers each time you need to use set.seed. The best way to work through the code is to use the help function for each command that you do not know (or Google it, most help files are online). If you need access to R and cannot install it on your own computer, you can use RStudio Cloud.

1 Like