Skip to content
Prev 267299 / 398503 Next

error in self-made function - cannot deal with objects of length = 1

But if you do mean to divide by max(x), I'll also vote for the prior

ROI <- function(x) {
if (length(x)==1) return(NA)
r=c(x[1], diff(x))/max(x)
return(r)}

As being about as quick and elegant as this can be done in R. 

M
On Aug 1, 2011, at 4:07 PM, "R. Michael Weylandt <michael.weylandt at gmail.com>" <michael.weylandt at gmail.com> wrote: