9.5: Answers to exercises
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):