Assessment Questions: Lists in R

Nov 3, 2013 • Matt Landis

Novice from Competent

Which of the following cannot be elements in a list?

a) data.frame

b) matrix

c) function

d) list

e) none of the above

 

Competent from Expert

Given the following list:

children <- list(name=c(‘Willem’, ‘Ella’), age=c(12, 8), male=c(TRUE, FALSE))

which statement will return ‘Ella’ as a character vector?

a) children[‘name’] [ !children[‘male’] ]

b) children[‘name’] [ !children[[‘male’]] ]

c) children[[‘name’]] [ !children[‘male’] ]

d) children[[‘name’]] [ !children[[‘male’]] ]