{\rtf1\ansi\ansicpg1252\cocoartf1187

{\fonttbl\f0\fmodern\fcharset0 Courier;}

{\colortbl;\red255\green255\blue255;}

\margl1440\margr1440\vieww16980\viewh8340\viewkind0

\deftab720

\pard\pardeftab720


\f0\fs24 \cf0 #----------------------------------------------------------------------------------------------------#\

# DATA GENERATION EXERCISE 1\

#----------------------------------------------------------------------------------------------------#\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\cf0 \

###Making a Dataset of our R Class###\

\

#We want to generate a dataset that has a variable for our names, our gender, our class year, and the numeric month of our birthday.\

\

# STEP 1\

#Names: Create a vector with all the names of the people in this class\

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li1026\fi-410\pardirnatural

\cf0 #Tip 1: Have as much foresight as possible when manipulating data to try and save yourself steps down the road. In this case, we are going to order the names by gender since we know we want that in our data set. \

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li1026\fi-410\pardirnatural

\cf0 Jaime, Meg, Meredith, Xiao, Ana, Taylor, Wen, Drew, Zach, Brian, Paul, Keenan, Ethan, Scott, Daniel, Rob, Doug, Greg, Ira, Chris\

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li1026\fi-410\pardirnatural

\cf0 #Tip #2: TextEdit and "Find and Replace" will be your friend. Copy and paste the above list of names into TextEdit and alter it so that the names are in quotes\

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li1026\fi-410\pardirnatural

\cf0 members <- c()\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\cf0 \

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\cf0 # STEP 2\

#Gender. Use the "rep" command to generate a vector of people's genders based on the order in which they appear in your vector of names\

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\fi590\pardirnatural

\cf0 gender <- \

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\cf0 \

\

#STEP 3\

#Year and Birth Month: Make vectors for people's graduation year and the month in which they were born (called "year" and "bdaymonth" respectively)\

\

\

\

\

#STEP 4\

#Bind the vectors together, using three different commands.\

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\fi555\pardirnatural

\cf0 Rclass <- data.frame(members, gender, year, bdaymonth)\

\

Rclassmatrix <- cbind(members, gender, year, bdaymonth)\

\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\fi555\pardirnatural

\cf0 Rclassmatrix2 <- rbind(members, gender, year, bdaymonth)\

\

Rclassmatrix3 <- matrix(members, gender, year, bdaymonth)\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\fi555\pardirnatural

\cf0 \

\

\

#What problem do you encounter in the last line of code?\

#What are the differences between these different objects?\

\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\cf0 \

\

}