Appendix
Answers to Exercises
This appendix provides the solutions for the end-of-chapter exercises located in Chapters 1–12.
Chapter 1
Exercise 1 Solution
To install the coin library/package you need to type the following command:
>install.package(‘coin’)
Note that the name must be in quotes. Then you select the closest mirror site and the package is downloaded and installed for you.
Exercise 2 Solution
To load the coin library and make it ready to use you type the following:
>library(coin)
Once the library is active its commands are available for you to use. You can try to bring up the help entry for the package using the following:
>help(coin)
This does not work for all packages; a better alternative is to use the HTML help system by typing:
>help.start()
This opens the main R help files in your default browser. You can now follow the links to the packages and then find coin from the list.
Exercise 3 Solution
The MASS package is already loaded as part of the R installation but is not ready to use until you type:
>library(MASS)
Once you have the library available you can open the help entry using:
>help(bcv)
Exercise 4 Solution
You can use the search() command to get a list of objects that are available for use.
Exercise 5 Solution
To clear the coin package from memory (and remove it from the search() path), type the following:
>detach(package:coin)
Chapter 2
Exercise 1 Solution
You can use either the c() command or the scan() command to enter these data. The problem is that ...
Get Beginning R: The Statistical Programming Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.