Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In the exercises below we cover the basics of lists. Before proceeding, first read section 6.1-6.2 of An Introduction to R, and the help pages for the `sum`, `length`, `strsplit`, and `setdiff` functions.

Answers to the exercises are available here.

Exercise 1
If:
`p ` and
`x `,
then what is the value of `x`?
a. NULL
b. “A” “B” “C”
c. “7”

Exercise 2
If:
`w `
`v `
`x `,
then which R statement will replace “A” in `x` with “K”.
a. ` x[] `
b. ` x[] `
c. ` x[] `

Exercise 3
If `a `, which R statement will give the sum of all elements in `a`?
a. `sum(a)`
b. `sum(list(a))`
c. `sum(unlist(a))`

Exercise 4
If `Newlist `, write an R statement that will add 1 to each element of the first vector in `Newlist`.

Exercise 5
If `b `, write an R expression that will give all elements, except the second, of the first vector of `b`.

Exercise 6
Let `x `, write an R statement to add a new item z = “NewItem” to the list x.

Exercise 7
Consider `y `, write an R statement that will assign new names “one”, “two” and “three” to the elements of y.

Exercise 8
If `x `, write an R statement that will give the length of vector `r` of `x`.

Exercise 9
Let `string `, write an R statement to split this string into two and return the following output:

``` []  "Grand" []  "Opening" ```

Exercise 10
Let:
`y ` and
`q `.
Write an R statement that will return all elements of q that are not in y, with the following result:

``` []  "A" []  "B" []  "C" ```