Vectors

  1. Create four vectors each with at least five values of your choosing. Each vector must have a different class type and should be assigned to an object with an (at least semi-) informative name. Show the code that created the vector, displayed the contents of the vector, and demonstrated the class of the vector.

  2. With one of your vectors from the first question, demonstrate code that will show one specific element in the vector.

  3. With one of your vectors from the first question, demonstrate code that will show multiple specific elements in the vector.

 

Data Frames I

  1. Create a data frame that has at least three related variables recorded on at least five individuals. You may use the same variables/data as in the “Vectors” question if the data in your vectors are related. Show the code that created the data frame, displayed the full contents of the data frame, and displayed the structure of the data frame.

  2. Show how to find one specific element (or value) in your data frame.

  3. Show how to isolate a single row from your data frame.

  4. Show how to isolate multiple rows from your data frame.

  5. Show three methods to isolate a single variable from your data frame.

 

Data Frames II

A student asked five male and five female students what their home state is. The data are recorded in the two tables below. Which one of these tables in a “tidy” format? Explain your reasoning.

Data frame 1
male female
TX IL
IA WI
WI WI
WI OH
MN CA
Data frame 2
gender state
male TX
female IL
male IA
female WI
male WI
female WI
male WI
female OH
male MN
female CA

 

Data Frames III

A student asked five students what their home state is and how they got to campus. The data are recorded in the two tables below. Which one of these tables in a “tidy” format? Explain your reasoning.

Data frame 1
student state transpo
1 TX plane
2 IA car
3 WI car
4 WI car
5 MN moped
Data frame 2
student question answer
1 state TX
1 transpo plane
2 state IA
2 transpo car
3 state WI
3 transpo car
4 state WI
4 transpo car
5 state MN
5 transpo moped

 

Data Frames IV

Enter the following credit load by year-in-school data into a data frame in tidy format. Show the code that created the data frame, displayed the full contents of the data frame, and displayed the structure of the data frame.

First-Year  12  14  17  12
Sophomore   15  16  14
Junior      13  16  15  15  13
Senior      12  17