# Traceability matrix

## Setup environment

Load the necessary package and set CRAN repository.

    library(risk.assessr)
    options(repos = "http://cran.us.r-project.org")

## Run traceability matrices and risk assessment

Analyze the stringr package to create a traceability matrix.

There are a number of ways to do this:

Firstly, if you just want a traceability matrix with no test coverage, you can run the following code:

    stringr_tm_no_test <- risk.assessr::generate_traceability_matrix("stringr", version = "1.5.1" )

    str(stringr_tm_no_test$tm)

Secondly, if you want a traceability matrix with test coverage, you can run the following code:

    stringr_tm_test <- risk.assessr::generate_traceability_matrix("stringr", version = "1.5.1", execute_coverage = TRUE)

    str(stringr_tm_test$tm)

If you want a full analysis of the package containing a traceability matrix and ither risk data, you can run the following:

    stringr <- risk.assessr::assess_pkg_r_package("stringr", version = "1.5.1" )

This returns a structured list with traceability and function risk information.

## Structure of traceability matrices

    str(stringr$tm_list)

## Get coverage summary by risk level

See how functions are mapped to risk and test coverage. This shows all the exported functions.

    stringr$tm_list$tm

This shows functions categorized as high, medium, or low risk test coverage.

    stringr$tm_list$coverage

### High risk test coverage

    stringr$tm_list$coverage$high_risk

### Medium risk test coverage

    stringr$tm_list$coverage$medium_risk

### Low risk test coverage

    low_risk <- stringr$tm_list$coverage$low_risk
    low_risk

## View function type summary

This shows functions categorized by higher risk function types.

### Defunct Functions

    stringr$tm_list$function_type

### Imported functions

    stringr$tm_list$function_type$imported

### Re-exported functions

    stringr$tm_list$function_type$rexported

### Experimental functions

    stringr$tm_list$function_type$experimental