sort

What it does

Checks for usage of x[order(x, ...)].

Why is this bad?

It is better to use sort(x, ...), which is more readable than x[order(x, ...)] and more efficient.

Example

x <- c(3, 2, 5, 1, 5, 6)
x[order(x)]
x[order(x, na.last = TRUE)]
x[order(x, decreasing = TRUE)]

Use instead:

x <- c(3, 2, 5, 1, 5, 6)
sort(x)
sort(x, na.last = TRUE)
sort(x, decreasing = TRUE)

References

See ?sort