**Unformatted text preview:**

Stats 10 Lab 1 Submission Name Kelsey Ash UID 805062994 Section 1 1 a heights c 64 74 70 heights 1 64 74 70 creates a vector by combining the code and naming it heighhts b names c Kelsey Tyler Tabi names 1 Kelsey Tyler Tabi creates a vector by combining the code and naming it names c cbind heights names heights names 1 64 Kelsey 2 74 Tyler 3 70 Tabi b head NCbirths This command matched the given height of each student to their corresponding name by taking the 2 different vectors and combining them to form a matrix This class of this new object is a matrix 2 a NCbirths read csv births csv Tells code what data set we want the computer to use use head followed by the function to see if my previous command code in the pervious problem worked to make sure I am using the correct working directory Gender Premie weight Apgar1 Fage Mage Feduc Meduc TotPreg Visits Marital 1 Male No 124 8 31 25 13 14 1 13 Married 2 Female No 177 8 36 26 9 12 2 11 Unmarried 3 Male No 107 3 30 16 12 8 2 10 Unmarried 4 Female No 144 6 33 37 12 14 2 12 Unmarried 5 Male No 117 9 36 33 10 16 2 19 Married 6 Female No 98 4 31 29 14 16 3 20 Married Racemom Racedad Hispmom Hispdad Gained Habit MomPriorCond BirthDef 1 White White NotHisp NotHisp 40 NonSmoker None None 2 White White Mexican Mexican 20 NonSmoker None None 3 White Unknown Mexican Unknown 70 NonSmoker At Least One None 4 White White NotHisp NotHisp 50 NonSmoker None None 5 White Black NotHisp NotHisp 40 NonSmoker At Least One None 6 White White NotHisp NotHisp 21 NonSmoker None None DelivComp BirthComp 1 At Least One None 2 At Least One None 3 At Least One None 4 At Least One None 5 None None 6 None None finds the package I want find package maps 3 a b library maps map state 1 Library Frameworks R framework Versions 4 0 Resources library maps checks to make sure I have the package properly downloaded within my R library Assigns the term weights to the weight of the babies found in the NCbirths data set 3 a weights NCbirths weight head weights 1 124 177 107 144 117 98 b c d I think the weights are in the unit of ounces 16oz lbs weights in pounds weights 16 head weights in pounds 1 7 7500 11 0625 6 6875 9 0000 7 3125 6 1250 gives the 1st 20 variables in this data set weights in pounds 1 20 converts the data weight given in ounces to pounds by dividing by 16 and assigning a new name to this conversion titled weights in pounds 1 7 7500 11 0625 6 6875 9 0000 7 3125 6 1250 9 1875 8 6250 6 5000 7 6875 11 9 5625 8 0625 7 4375 6 7500 6 6250 7 8125 7 1875 8 0000 8 2500 5 1875 finds the mean of the weights in lbs mean weights in pounds The mean weight of the babies in pounds is 7 2532 lbs gives the percent of mothers who smoke from the NCbirths data set tally NCbirths Habit format percent 2 Section 2 1 1 7 2532 2 3 Smoker 9 38755 9 39 smokers Smoker 11 61245 Section 3 1 gives the difference between the CDC percent and the actual percent of smoking mothers we found 21 tally NCbirths Habit format percent 2 The percentage I found in 2 is 11 61 off from the CDC s report gives a dot plot graph of the babies weights in lbs with the x axis titled accordingly and increasing the size of the data points cex 5 dotPlot weights in pounds cex 5 2 creating 3 different histograms to compare the data set of the babies weights in lbs by assigning different numbers of bars breaks histogram weights in pounds breaks 3 histogram weights in pounds breaks 20 histogram weights in pounds breaks 100 The histogram with 20 bins seems to give the best visualization because it gives the most information without being too overwhelming and therefore gives the most accurate graph shape 3 gives a boxplot diagram to compare the mother s age to the father s age side by side According to the boxplot it looks like the father s age tends to be older boxplot NCbirths Mage NCbirths Fage 4 This histogram shows a direct comparison by placing the graphs side by side between the effect that smoking had on the weight of the babies histogram weight Habit data NCbirths layout c 1 2 determines the X axis in this case it s the babies weights the bar separates the data set by variable the habit of smokers vs nonsmokers in the data set NCbirths is the variable we are concerned with in this case the c combines the 2 variables in 1 diagram and the layout command tells the code how we want the graph to be displayed Section 4 1 determines the X axis in this case it s the number of premature babies the bar separates the data set by variable the habit of smokers vs nonsmokers in the data set NCbirths is the variable we are concerned with in this case the format tells the computer how we want the data to be shown Of the other categorical variables which records the health of the baby I think the baby s prematurity will be associated with the mother s smoking because mother s who smoke while pregnant can cause premature birth due to the carcinogens found in cigarettes Based on the two way data table listed below my hypothesis was correct since the table below shows that we would expect a greater percentage of premature babies from the smokers group compared to the nonsmokers group since the data table shows that about 9 of babies are born premature from members of the nonsmoker group vs the higher percentage of babies that are born premature from the smoker group being about 12 tally Premie Habit data NCbirths format proportion Habit Premie NonSmoker Smoker No 0 91191136 0 88235294 Yes 0 08808864 0 11764706 Section 5 1 Makes a scatterplot with the Mother s age on the x axis NCbirths Mage and the Baby s weight on the y axis with dots pch 19 plot NCbirths weight NCbirths Mage col red cex 0 5 pch 19 xlab Age of Mother ylab Baby Weight oz main Baby Weight vs Age of Mother Section 6 1 AQI colors in combination with AQI levels changes the colors of the points in each range I also used the pch 19 command to change the shape of the points AQI colors c green yellow orange dark orange red AQI levels cut a o3 c 0 0 06 0 075 0 104 0 115 0 374 as numeric AQI levels 1 1 3 1 3 1 3 1 1 1 1 3 2 1 1 1 3 2 3 3 …

View Full Document