hydromad
hydromad copied to clipboard
Avoid 1:ncol(...) expressions, use seq_len
Lintr warning:
##[warning]Avoid 1:ncol(...) expressions, use seq_len.
##[warning]Avoid 1:NCOL(...) expressions, use seq_len. ##[warning]Avoid 1:NROW(...) expressions, use seq_len. ##[warning]Avoid 1:length(...) expressions, use seq_len. ##[warning]Avoid 1:nrow(...) expressions, use seq_len.
Can we discuss this a bit. If the object (...) is a matrix, we would have to do: seq_len(...[,1])?? Or use dim()? What do you suggest. I guess they don't like 1:..?
Mentioning this as there are a few I come across in my editing Can fix them on the go
There's seq_along(along.with)
and seq_len(length.out)
. The first just uses the length of the object. The behaviour is unclear for matrices, so it's better to do seq_len(NROW(object))
for instance.
These shouldn't be too hard to find-and-replace, so it's up to you whether it's easy enough to do them while you're working on other things.