Convert a coverage object to a data frame
Usage
# S3 method for class 'coverage'
as.data.frame(x, row.names = NULL, optional = FALSE, sort = TRUE, ...)Arguments
- x
a coverage object.
- row.names, optional
ignored, for compatibility with
base::as.data.frame().- sort
if
TRUE(the default), sum the counts of identical expressions and sort the rows by file and position. IfFALSE, there is one row for each element ofx, in the same order.- ...
ignored.
Value
A data frame with one row for each traced expression of R code and each line of compiled code, and the columns:
filename: the source file, relative to therootattribute ofx(the package directory, forpackage_coverage()) if there is one.functions: the name of the function containing the expression, orNAfor compiled code.first_line,last_line: the lines the expression starts and ends on.first_byte,last_byte: the bytes of those lines the expression starts and ends at.first_column,last_column: the columns the expression starts and ends at. These differ from the bytes when the line contains multibyte characters.first_parsed,last_parsed: the lines as seen by the parser. These differ fromfirst_lineandlast_linewhen the source uses#linedirectives.value: the number of times the expression was executed.
Use tally_coverage() for one row for each line instead.
Examples
cov <- code_coverage("add <- function(x, y) { x + y }", "add(1, 2)")
as.data.frame(cov)
#> filename functions first_line first_byte
#> 1 /tmp/RtmpvpKgL4/source.R190e7ea4e117 add 1 25
#> last_line last_byte first_column last_column first_parsed last_parsed value
#> 1 1 29 25 29 1 1 1
