Learn R Programming

gamclass (version 0.56)

matchedPairs: Collect together driver and right seat passenger information, for the specified year

Description

This function collates the information needed for a matched pairs analysis. Driver mortalities, with and without airabgs, are matched to passenger mortalities for right front seat passengers in cars without passenger airbags. It was used to generate the FARS and FARSmiss datasets

Usage

matchedPairs(years = 2007:2008, prefix = "fars", compareBYvar = c("airbagAvail",
    "airbagDeploy", "Restraint"),
    bycat = list(airbagAvail = list(yes = c(1:9, 20, 28:29, 31:32), no =30,
    leaveout = c(0, 98, 99)),
    airbagDeploy = list(yes = c(1:9),
    no = c(20, 28, 30:32), leaveout = c(0, 29, 98, 99)),
    Restraint = list(yes = c(1:4, 8, 10:12, 97), no = c(0, 5, 6, 7, 13:17),
    leaveout = (98:99))),
    restrict = "body%in%c(1:19,48,49,61,62)&!(mhevent%in%(2:5))",
    restrictvars = c("body", "mhevent", "seatpos", "injury"),
    retain = c("state", "age", "airbag", "injury", "restraint",
        "sex", "inimpact", "modelyr"), progress = TRUE)

Arguments

years

Years for which data is required

prefix

Prefix for file name.

compareBYvar

Variables to be included in output, selected from airbagAvail, airbagDeploy and Restraint), for which deaths are to be compared between drivers (w/wo

bycat

Maps airbag and restraint codes to yes, no or leaveout

restrict

Allows restriction of data to specified variable subsets.

restrictvars

character vector: names of variables that appear in the restrict argument

retain

Retain these columns in the output data

progress

Print year by year details of the progress of calculations.

Value

data

Data frame, with driver information matched against passenger information for the same vehicle

miss

3-way table holding missing data information. The table is has margins state, a set of variable names, and years

Details

This function is designed for processing data obtained from the FARS url noted under references. This function was used to generate the data in the FARS data frame. Two of the datasets from which the FARS dataset was generated are included with this package -- these are fars2007 and fars2008

References

http://www-fars.nhtsa.dot.gov/Main/index.aspx

See Also

plotFars, FARS, fars2007

Examples

Run this code
# NOT RUN {
farsMatch0708 <- matchedPairs(years=2007:2008)
# }

Run the code above in your browser using DataLab