Docsity

Computer Project: Data Analysis with R - Part 1, Study Guides, Projects, Research of Mathematics

Toggle sidebar
bg1
ComputerProject1:Duedate,MondayJune8,2009
Instructions:WriteyousolutionsinaWordfile(orpreferablypdffile)andalongwithyourRprogram(s)
e‐mailthemtomeinasinglezip‐file.Thenameofthezip‐fileshouldbeYourLastName1.zip,where
“YourLastName”isreplacedbyyourlastname.Yoursolutionshouldincludeyourinputandoutputfiles,
organizednicely.
ThegoalofthisexerciseistofamiliarizeyouwithinputtingdataintoR,manipulatingdata,andgetting
youfamiliarwithsomegraphicfunctionsinR.Makesurethatyourplotsarecompletelylabeled,
includingamaintitle,andx‐labelandy‐label,wheneverrelevant.
1. Considerthe
followingdata:
CrashTestData: Databasedontrialsinwhichstockautomobilesarecrashedintoawallat35MPH
withdummiesinthedriverandfrontpassengerseat.
Reference:NationalTransportationSafetyAdministration
Numberofcases:352
VariableNames:
1) Make:Carmake
2) Model:Modelofthatcar
3) carID:Usuallythecombinationofmakeandmodel
4) carID_&_Year:FullIDofthecar
5) Head_IC:Headinjurycriterion
6) Chest_decel:Chestdeceleration
7) L_Leg:Leftfemurload
8) R_Leg:Rightfemurload
9) D/P:WhetherthedummyisintheDriverorPassengerseat
10) Protection:Kindofprotection(seatbelt,airbag,etc.)
11) Doors:Numberofdoorsonthecar
12) Year:Yearofthecar
13) Wt:Weightinpounds
14) Size:Acategoricalvariabletoclassifythecarstoatype(light,minivan)
a) Giveabarplotthatindicatesthenumberofeachtypeofprotectionused.Thecolorofthebars
shouldbered.Note,it’sbestthatbarplotsareorderedfromlargesttosmallest.
b) Giveabarplotthatindicatesthepercentageofeachtypeofprotectionused.
c) Giveapie‐chartthatindicatesthepercentageofeachtypeofprotectionused.Makesurethat
thepieslicecorrespondingto“manualbelts”isred,andthepercentagesappearwiththeslice
labels.
pf3

Partial preview of the text

Download Computer Project: Data Analysis with R - Part 1 and more Study Guides, Projects, Research Mathematics in PDF only on Docsity!

Computer Project 1: Due date, Monday June 8, 2009 Instructions: Write you solutions in a Word file (or preferably pdf file) and along with your R program(s) e‐mail them to me in a single zip‐file. The name of the zip‐file should be YourLastName1.zip, where “YourLastName” is replaced by your last name. Your solution should include your input and output files, organized nicely. The goal of this exercise is to familiarize you with inputting data into R, manipulating data, and getting you familiar with some graphic functions in R. Make sure that your plots are completely labeled, including a main title, and x‐label and y‐label, whenever relevant.

  1. Consider the following data: Crash Test Data : Data based on trials in which stock automobiles are crashed into a wall at 35MPH with dummies in the driver and front passenger seat. Reference: National Transportation Safety Administration Number of cases: 352 Variable Names:
    1. Make: Car make
    2. Model: Model of that car
    3. carID: Usually the combination of make and model
    4. carID_&_Year: Full ID of the car
    5. Head_IC: Head injury criterion
    6. Chest_decel: Chest deceleration
    7. L_Leg: Left femur load
    8. R_Leg: Right femur load
    9. D/P: Whether the dummy is in the Driver or Passenger seat
    10. Protection: Kind of protection (seat belt, air bag, etc.)
    11. Doors: Number of doors on the car
    12. Year: Year of the car
    13. Wt: Weight in pounds
    14. Size: A categorical variable to classify the cars to a type (light, minivan) a) Give a bar plot that indicates the number of each type of protection used. The color of the bars should be red. Note, it’s best that barplots are ordered from largest to smallest. b) Give a bar plot that indicates the percentage of each type of protection used. c) Give a pie‐chart that indicates the percentage of each type of protection used. Make sure that the pie slice corresponding to “manual belts” is red, and the percentages appear with the slice labels.
  1. Consider the following data set: Colleges data: These data were collected from the 25 top liberal arts colleges and the 25 top research universities. Number of cases: 50 Variable Names: 1) School: Contains the name of each school 2) School_Type: Coded 'LibArts' for liberal arts and 'Univ' for university 3) SAT: Median combined Math and Verbal SAT score of students 4) Acceptance: % of applicants accepted 5) $/Student: Money spent per student in dollars 6) Top_hs: % of students in the top 10% of their h.s. graduating class 7) %PhD: % of faculty at the institution that have PhD degrees 8) Grad%: % of students at institution who eventually graduate a) Plot a stem‐and‐leaf display for the variable SAT, including all the data. Then plot separate stem‐and‐leaf displays for the variable SAT for each of the two types of colleges. Choose your scale variable in R so that your graph is most informative. Comment on the shape of each of the distributions and give your interpretation of the shape. b) Plot a histograms of the data for the variables SAT: i. Set break points with intervals of length 50, starting at 1100. ii. Set break points with intervals of length 25, starting at 1100. iii. Comment on how your histogram in (i) differs from histogram in (ii). c) Plot two histograms, on the same plot, of variable Accept, one for the universities and one for the liberal arts colleges. To create a variable that contains the values of Accept for the universities you can use the syntax Accept[Type==’Univ’]. To have two graphs on the same plot use the command par(mfrow=c(1,2))before you issue your plot command. Comment on the differences that you observe between university and liberal art colleges with respect to the variable ACCEPT. d) Use R to obtain the five‐number summary for the variable Grad. Interpret the first and third quartile values. e) Use R to obtain mean, standard deviation for the variable SAT separately for each of the school types. Compute the z‐score corresponding to an SAT score of 1250. Based on your z‐score, do universities or the liberal arts schools have a higher SAT score standard? f) In a single plot include four graphs that compares the values of variables SAT, Spent, Top_hs, and PhD. The command par(mfrow=c(2,2)) will be useful. Identify the outliers on the plot (the commands text, and locator will be useful). Give a short interpretation of each graph, including outliers. g) Ask R to list the name of all the liberal arts colleges for which the variable SAT is more than 1300. h) Plot the normal probability plots for each of the variables SAT, Spent, Top_hs, and PhD and comment on the shape of the distributions. Then for each of the four variables compute the