Skip to content
Prev 201888 / 398506 Next

Simple Function doesn't work?

Hi,

If you execute the following code it works but I wouldn't use grid if I 
were you as a vector as this name is already used by R (check 
help(grid)) and it explains why you have to define it in the function.

ReturnsGrid = function(x,y,m){
grid <- numeric(m)
for (i in 1:m){
   grid[i] <- x + (i-1)*(y-x)/m
}
grid
}

xx=ReturnsGrid(0,9,3)

Regards,
Alain
Anastasia wrote: