Skip to main content
Statistics LibreTexts

8.6: Answers to exercises

  • Page ID
    3601
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Answer to the question about mistake. This is it:

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

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

    Here should be

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

    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}\) (R):

    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.


    This page titled 8.6: 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.