Displaying 1 result from an estimated 1 matches for "tp3710555p3710621".
2011 Aug 01
3
error in self-made function - cannot deal with objects of length = 1
I have a function to calculate the rate of increase (the difference between
the value and the previous value divided by the total number of eggs in a
year) of egg production over the course of a year:
rate <- function(x){
storage <- matrix(nrow=length(x),ncol=1)
storage[1,] <- x[1] / max(x) # as there is no previous value
for( i in 2:length(x)){
p <- i - 1