Coding for Machines and Humans / R Packages

Author

Yenran Yiran

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.

stat210_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
stat210      <- data.frame(
  students = stat210_students, 
  exam  = exam_scores,
  extra = extra_credit, 
  total = total_score
)
stat210
  students exam extra 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 to create output with three different animals/sayings.

cowsay::say(
  what = "Q: Whooo are you?",
  by = "owl"
)

 ___________________ 
< Q: Whooo are you? >
 ------------------- 
    \
     \

       /\___/\
       {o}{o}|
       \ v  /|
       |    \ \
        \___/_/       [ab]
          | |
cowsay::say(
  what = "I am such a fun guy",
  by = "mushroom"
)

 _____________________ 
< I am such a fun guy >
 --------------------- 
             \
              \

                ________
           __--´      ° `--__
       __-´     °      °     `-__
     (´    °    °          °     `)
     (° °|    |°         ° |    | )
      `'''''''''`|'''''|´''''''''´
                 |     |
                 |:::::|
               /:|:::::|:\
              /::|:::::|::\
                 |     |
                 |^   ^|
                 |  _  | [FK]
                 |_____|
cowsay::say(
  what = "See you later!",
  by = "alligator"
)

 ________________ 
< See you later! >
 ---------------- 
                  \
                   \

           .-._   _ _ _ _ _ _ _ _
.-''-.__.-'00  '-' ' ' ' ' ' ' ' '-.
'.___ '    .   .--_'-' '-' '-' _'-' '._
V: V 'vv-'   '_   '.       .'  _..' '.'.
  '=.____.=_.--'   :_.__.__:_   '.   : :
           (((____.-'        '-.  /   : :
snd                          (((-'\ .' /
                           _____..'  .'
                          '-._____.-'