View source: R/matrix_apply_linter.R
matrix_apply_linter | R Documentation |
colSums(x)
or rowSums(x)
over apply(x, ., sum)
colSums()
and rowSums()
are clearer and more performant alternatives to
apply(x, 2, sum)
and apply(x, 1, sum)
respectively in the case of 2D
arrays, or matrices
matrix_apply_linter()
efficiency, readability
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = "apply(x, 1, sum)",
linters = matrix_apply_linter()
)
lint(
text = "apply(x, 2, sum)",
linters = matrix_apply_linter()
)
lint(
text = "apply(x, 2, sum, na.rm = TRUE)",
linters = matrix_apply_linter()
)
lint(
text = "apply(x, 2:4, sum)",
linters = matrix_apply_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.