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.
stat210students <- c ("Archie" , "Edith" , "Gloria" , "Meathead" , "Lionel" )
examscores <- c (67 , 89 , 73 , 71 , 84 )
extracredit <- c (5 , 3 , 6 , 9 , 5 )
totalscore <- examscores + extracredit
stat210 <- data.frame (students = stat210students, exam = examscores,
EC = extracredit, total = totalscore)
stat210
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 to create output with three different animals/sayings.
library (cowsay)
say (what = 'may i have a bacon cheeseburger please' , by = 'alligator' )
________________________________________
< may i have a bacon cheeseburger please >
----------------------------------------
\
\
.-._ _ _ _ _ _ _ _ _
.-''-.__.-'00 '-' ' ' ' ' ' ' ' '-.
'.___ ' . .--_'-' '-' '-' _'-' '._
V: V 'vv-' '_ '. .' _..' '.'.
'=.____.=_.--' :_.__.__:_ '. : :
(((____.-' '-. / : :
snd (((-'\ .' /
_____..' .'
'-._____.-'
say (what = 'stat 210 is fun' , by = 'stretchycat' )
_________________
< stat 210 is fun >
-----------------
\
\
,/| _.--‛‛^``-...___.._.,;
/, \‛. _-‛ ,--,,,--‛‛‛
{ \ `_-‛‛ ‛ /}‛
Jill `;;‛ ; ; ;
._.--‛‛ ._,,, _..‛ .;.‛
(,_....----‛‛‛ (,..--‛‛
say (what = 'lebron is the goat' , by = 'hypnotoad' )
____________________
< lebron is the goat >
--------------------
\
\
,'``.._ ,'``.
:,--._:)\,:,._,.:
:`--,'' :`...';\
`,' `---' `.
/ :
/ \
,' :\.___,-.
`...,---'``````-..._ |: \
( ) ;: ) \ _,-.
`. ( // `' \
: `.// ) ) , ;
,-|`. _,'/ ) ) ,' ,'
( :`.`-..____..=:.-': . _,' ,'
`,'\ ``--....-)=' `._, \ ,') _ '``._
_.-/ _ `. (_) / )' ; / \ \`-.'
`--( `-:`. `' ___..' _,-' |/ `.)
`-. `.`.``-----``--, .'
|/`.\`' ,','); SSt
` (/ (/