That's my bad, str()
won't work in that context. Let's try something else...
I've gone ahead and cleaned up the version of your code I am running and put an R file on my github here:
You should be able to simply download and run that R file, which will be easier than trying to find a possibly very small and minor typo.