Lab #1 Markdown File

Lab Instructions

In this lab we will be learning the basics of using R and working with real data.

See the “Instructions” section of the Lab Instructions page for more information about the labs. That page also gives descriptions for the datasets we will be using.

Required reading:

Optional resources:


Practice Questions

ex1. What is the sum of the values of some_vector?

some_vector <- c(25555,342343,123123123,4234234,53243234,54324234,5421111,12312312,111231)
sum(some_vector)
## [1] 253137377

ex2. Compute the sum of all integers 1 through 100, inclusive.

HINT: The solution to this problem is found in the required readings.

sum(seq(1, 100))
## [1] 5050

Questions


1. Use the documentation website or the helper functions in R (?function_name) to look up the mean function, and describe each of its arguments and what they do in your own words. Write your answer in the code block below as a comment.

NOTE: You can write comments in a code block by including a “#” character at the beginning of the line.

# Write your answer here.


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

NOTE: the first element index starts with 1 in R.

my_vector <- c("R","is","great")
# your code here


3. This question has several parts: (a) Use R code to identify the data type of some_vector. (b) What is the largest number in this vector? (c) How about the mean value? (d) Does this vector include the number 54324222? Your results should be generated from the R code - please do not write the numbers into R manually.

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.

HINT: check out the %in% operator.

some_vector <- c(25555,342343,123123123,4234234,53243234,54324234,5421111,12312312,111231,
                     1231231,12312312,12312312,123123,898972,789872,2343,23423423,2343221,23423,
                     14444,44324222,2342341,124231111,22233345,1111233333,1231231,1231231)
# your code here


4. Use the congress dataframe for the remainder of questions in this assignment. (a) How many rows and columns does the congress dataframe have? (b) Use a function to show its data type. You must use R code to generate these values.

# your code here


5. Using the browse features of R or RStudio, write the ages of Sherrod Brown (a member of congress) and Dianne Feinstein.

Your written response here.
Sherrod Brown: 
Dianne Feinstein: 


6. What is the average birthyear of congress members? What is the data type of the birthyear column?

# your code here


7. What are your learning goals for this semester? Not a trick question ;)

your written response here