Description Usage Arguments Value See Also Examples
Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code. It was developed by Thomas J. McCabe, Sr. in 1976.
Calculate the cyclomatic complexity of an R function or expression.
1 2 3 | cyclocomp(expr)
cyclocomp_q(expr)
|
expr |
An R function or expression. |
Integer scalar, the cyclomatic complexity of the expression.
Other cyclomatic complexity: cyclocomp_package_dir
,
cyclocomp_package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | ## Supply a function
cyclocomp(
function(arg) { calulate(this); and(that) }
)
cyclocomp(ls)
cyclocomp(cyclocomp)
## Or a quoted expression
cyclocomp(quote( if (condition) "foo" else "bar" ))
## cyclocomp_q quotes the expression for you
cyclocomp_q(while (condition) { loop })
## Complexity of individual control flow constructs
cyclocomp(quote({
if (condition) this
}))
cyclocomp(quote({
if (condition) this else that
}))
cyclocomp(quote({
for (var in seq) expr
}))
cyclocomp(quote({
while (cond) expr
}))
cyclocomp(quote({
repeat expr
}))
cyclocomp(quote({
for (var in seq) {
this
break
that
}
}))
cyclocomp(quote({
for (var in seq) {
this
next
that
}
}))
|
[1] 1
[1] 10
[1] 1
[1] 2
[1] 3
[1] 2
[1] 2
[1] 3
[1] 3
[1] 2
[1] 4
[1] 4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.