Primary exercises
Create and investigate a list.
Three students received different sets of grades (Amy: 1,6,7,9,10; Bob: 6,7,4,3,5,2,2,1,4; Dan: 9,9,10).
In a variablescores
create alist
(the names of the list elements should be the names of the students and the values should be the corresponding grades).
Print the list, itsclass
,length
and structure (str
) ofscores
.Add an element, change an element.
Reusescores
from the previous exercise.
Add there grades for Eve (7,3,5,8,8,9) and print the list.
Then, for Dan merge new grades (8,8,6,7) with the existing grades (hint: use the combine functionc
to combine existing Dan’s grades with the new grades then put the result back toscores
; do not type again9,9,10
).Single and double bracket operators.
Reusescores
from the previous exercises.
Investigate the difference betweenscores[[ "Bob" ]]
andscores[ "Bob" ]
.
Look at what is printed and what is the class of each result.
Then comparescores[[ c( "Amy", "Bob" ) ]]
withscores[ c( "Amy", "Bob" ) ]
.
Understand, why the error is reported.Dollar operator.
Reusescores
from the previous exercises.
Investigate the (lack of) difference betweenscores$Bob
andscores[[ "Bob" ]]
.
Look at what is printed and what is the class of each result.
Then comparescores$Bo
withscores[[ "Bo" ]]
.
Understand, why theNULL
is returned.