This is the function I created, how can I make the main argument a simple vector of numeric values?.
IndexofDispersion<- function(X, ...) {
return( var(X, ...)/mean(X,...))
}
This is the function I created, how can I make the main argument a simple vector of numeric values?.
IndexofDispersion<- function(X, ...) {
return( var(X, ...)/mean(X,...))
}
to run the function with a simple vector of numeric values you can do
IndexofDispersion(X=c(1,0,2,3,3.5))
the result will be 1.078947
Thanks. I have another question. I created the function
IndexofDispersion<- function(X, ...) {
return( var(X, ...)/mean(X,...))
}
I have to test it on a data set like "horsekicks" but it is a data frame, so I get
Warning message:
In mean.default(X, ...) : argument is not numeric or logical: returning NA
What can i do?
Im not familiar with horsekicks, would you run your function on any particular variable/column of that?
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.