Skip to main content
[ "article:topic", "showtoc:no", "authorname:ashipunov", "license:publicdomain", "jupyter:r" ]
Statistics LibreTexts

B.5: Answers to exercises

  • Page ID
  • 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!

    Screen Shot 2019-01-31 at 12.36.15 AM.png

    (And this concluding image was made with command:)

    Code \(\PageIndex{1}\) (Python):

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