replacement has length zero in R from a python code
Keep in mind that R indexes are 1-based, while in Python they are 0-based. In your code, the first time through the for loop, u[i, j - 1] evaluates to u[2, 0], or numeric(0). This is what produces the error.
I was doing numerical method in R and Python
I have applied leapfrog method in python and it worked perfectly but I want to do the slimier thing in R. Here you can see my code 
Possibly I have tried doing u[2,2]=beta*(u[1,1]-2*u[2,1]+u[3,1]) this works, here I can see that the error is due to the bold statement means due to u[2,0] does not exist. But the same code worked in python, Please help to resolve the error while executing the loop
u[i, j - 1] evaluates to u[2, 0], or numeric(0). This is what produces the error.
Is there any solution.