Vectors
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.
With one of your vectors from the first question, demonstrate code that will show one specific element in the vector.
With one of your vectors from the first question, demonstrate code that will show multiple specific elements in the vector.
Data Frames I
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.
Show how to find one specific element (or value) in your data frame.
Show how to isolate a single row from your data frame.
Show how to isolate multiple rows from your data frame.
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.
male | female |
---|---|
TX | IL |
IA | WI |
WI | WI |
WI | OH |
MN | CA |
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.
student | state | transpo |
---|---|---|
1 | TX | plane |
2 | IA | car |
3 | WI | car |
4 | WI | car |
5 | MN | moped |
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