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

A.6: Answers to exercises

  • Page ID
    3601
  • Answer to the question about mistake. This is it:

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

    data <- read.table("data/bugs.txt", h=TRUE)
    hist(data$WEIGHT, breaks=c(seq(0, 100, 20))
    

    Here should be

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

    data <- read.table("data/bugs.txt", h=TRUE)
    hist(data$WEIGHT, breaks=c(seq(0, 100, 20)))
    

     By the way, non-paired brackets (and also non-paired quotes) are among the most frequent mistakes in R.

    Even more, function seq() makes vector so function c() is unnecessary and the better variant of the same command is

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

    data <- read.table("data/bugs.txt", h=TRUE)
    hist(data$WEIGHT, breaks=seq(0, 100, 20))
    

    Now the truth is that there are two mistakes in the text. We are sorry about it, but we believe it will help you to understand R code better. Second is not syntactic mistake, it is more like inconsistency between the text and example. Please find it yourself.