This is not helping too much. Reproducible example would allow me to run your code on my machine and see output.
Based on your screenshot it's not clear to me what can be the error in this case.
In general, this error will be thrown when psite argument is not an a number, but NULL, for example:
> rep(1, times = NULL)
Error in rep(1, times = NULL) : invalid 'times' argument
Why it's happening in your case is not clear, though.