
Answer to question about book code. If you are really attentive, you might find that some lines of code are preceded by space before greater sign. For example, q() in the second chapter. Of course, I do not want R to exit so early. This is why this code is not processed.

Now you can find other examples and think why they do not go trough R.

Answer to question about recreating the object impied in “bad” script. Our new object apparently is a list and requires subsetting with double brackets whereas original object was likely a matrix, with two columns, each representing one species.

We can stack() our list and make it the data frame, but this will not help us to subset exaclty like in original version.

The other way is to make both species parts exactly equal lengths and then it is easy to make (e.g., with cbind()) a matrix which will consist of two columns-species. However, this will result in loosing some data. Maybe, they did use some different version of data? It is hard to tell. Do not make bad scripts!

(And this concluding image was made with command:)

Code $$\PageIndex{1}$$ (R):

Gridmoon(Nightsky=FALSE, Moon=FALSE, Stars=FALSE, Hillcol="forestgreen", Text="Use R script!", Textcol="yellow", Textpos=c(.35,.85), Textsize=96) # gmoon.r

This page titled 9.5: Answers to exercises is shared under a Public Domain license and was authored, remixed, and/or curated by Alexey Shipunov via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.