Coding for Machines and Humans / R Packages

Author

Michael Ernst

Published

January 27, 2026

Section 1.4 Coding for Machines and Humans

Read Section 1.4 in Hello Data Science and peruse Chapter 2 of the Tidyverse style guide. Using what you’ve learned, modify the code below to be more readable and consistent with these guidelines.

stat_210_students <- c("Archie", "Edith", "Gloria", "Meathead", "Lionel")
exam_scores <- c(67, 89, 73, 71, 84)
extra_credit <- c(5, 3, 6, 9, 5)
total_score <- exam_scores + extra_credit
stat_210 <- data.frame(students = stat_210_students, exam = exam_scores,
                       EC = extra_credit, total = total_score)
stat_210
  students exam EC total
1   Archie   67  5    72
2    Edith   89  3    92
3   Gloria   73  6    79
4 Meathead   71  9    80
5   Lionel   84  5    89

Section 1.5 R Packages

Go to the Console and install the cowsay package. Add code below that loads the package and then test out the say() function by using it create output with three different animals/sayings.

library(cowsay)
say(what = "Hello woRld!")

 ______________ 
< Hello woRld! >
 -------------- 
      \
       \

        ^__^ 
        (oo)\ ________ 
        (__)\         )\ /\ 
             ||------w|
             ||      ||
say(what = "All glory to the Hypnotoad! ", by = "hypnotoad")

 _____________________________ 
< All glory to the Hypnotoad! >
 ----------------------------- 
                \
                 \

                ,'``.._   ,'``.
                :,--._:)\,:,._,.:
                :`--,''   :`...';\
               `,'       `---'  `.
               /                 :
              /                   \
            ,'                     :\.___,-.
           `...,---'``````-..._    |:       \
             (                 )   ;:    )   \  _,-.
              `.              (   //          `'    \
               :               `.//  )      )     , ;
             ,-|`.            _,'/       )    ) ,' ,'
            (  :`.`-..____..=:.-':     .     _,' ,'
             `,'\ ``--....-)='    `._,  \  ,') _ '``._
          _.-/ _ `.       (_)      /     )' ; / \ \`-.'
         `--(   `-:`.     `' ___..'  _,-'   |/   `.)
             `-. `.`.``-----``--,  .'
               |/`.\`'        ,','); SSt
                   `         (/  (/
say(what = "Fear is the path to the dark side.
    Fear leads to anger. Anger leads to hate. Hate leads to suffering.",
    by = "yoda")

 ______________________________________________________ 
/ Fear is the path to the dark side.  Fear leads to    \
\ anger. Anger leads to hate. Hate leads to suffering. /
 ------------------------------------------------------ 
                \
                 \

                   ____
                _.' :  `._
            .-.'`.  ;   .'`.-.
   __      / : ___\ ;  /___ ; \      __
  ,'_ ""--.:__;".-.";: :".-.":__;.--"" _`,
  :' `.t""--.. '<@.`;_  ',@>` ..--""j.' `;
       `:-.._J '-.-'L__ `-- ' L_..-;'
          "-.__ ;  .-"  "-.  : __.-"
             L ' /.------.\ ' J
             "-.   "--"   .-"
             __.l"-:_JL_;-";.__
         .-j/'.;  ;""""  / .'\"-.
         .' /:`. "-.:     .-" .';  `.
      .-"  / ;  "-. "-..-" .-"  :    "-.
  .+"-.  : :      "-.__.-"      ;-._   \
  ; \  `.; ;                    : : "+. ;
  :  ;   ; ;                    : ;  : \:
  ;  :   ; :                    ;:   ;  :
  : \  ;  :  ;                  : ;  /  ::
  ;  ; :   ; :                  ;   :   ;:
  :  :  ;  :  ;                : :  ;  : ;
  ;\    :   ; :                ; ;     ; ;
  : `."-;   :  ;              :  ;    /  ;
 ;    -:   ; :              ;  : .-"   :
  :\     \  :  ;            : \.-"      :
  ;`.    \  ; :            ;.'_..--  / ;
  :  "-.  "-:  ;          :/."      .'  :
   \         \ :          ;/  __        :
    \       .-`.\        /t-""  ":-+.   :
     `.  .-"    `l    __/ /`. :  ; ; \  ;
       \   .-" .-"-.-"  .' .'j \  /   ;/
        \ / .-"   /.     .'.' ;_:'    ;
  :-""-.`./-.'     /    `.___.'
               \ `t  ._  /  bug
                "-.t-._:'