R Basics Quiz

A quiz to test your understanding

Additional Resources:


1. What arguments can you use for the mean function in R?

Hint: you can access the help file for any function in R by typing a question mark before its name: ?mean in the console

2. Extract the third element of the vector using numerical indexing.

random_vector <- c("R","is","great")

3. Use R code to identify the data type of some_vector. What is the largest number in this vector? How about the mean value?

Hint: you’ll have to research some new functions in r to do this- try Google or one of the tutorials linked on the syllabus.

some_vector <- c(25555,342343,123123123,4234234,53243234,54324234,5421111,12312312,111231,

**4. For the remainder of this quiz, we’ll look at a dataframe called congress. Run the code below to download the dataset from a Github site.

{r message=FALSE, echo=TRUE} load(url('https://dssoc.github.io/datasets/congress.RData'))

4. How many rows and columns does the congress dataframe have? Use a function to show its data type. You must use R code to generate these values.

5. What is the average age of all congress members? What is the data type of the birthyear column?

6. How much older is Sherrod Brown (a member of congress) compared to the average of members of congress? How about Dianne Feinstein?

7. Who are the oldest members of congress?

Return to Bootcamp page