function trows an error at first, but runs smoothly after being copy/pasted


TS Contributor
I am building a new version of a package of mine, and I came across a strange behavior of a function. This poped up after I made some change to the code. If I install the package (using, as usual, library(GmAMisc)) and run a function, an error is returned:
no method for coercing this S4 class to a vector
If I visualize the code, copy and paste it in the R console, and re-run the function, it runs as expected and no error is returned.
I am wondering what is actually causing that, and if it may depend on the sequence in which the dependencies are loaded upon loading my package.

Thanks for any elucidation you will be able to provide.



TS Contributor
Any suggestion on how can I produce that, considering that that would entail making the package available to others here? In other words, how can I share the package here without putting it on GitHub first? You know, my knowledge on those topics is not extensive :-(


TS Contributor
I think I solved the issue.
It seems it was indeed a conflict between packages and related functions. My workaround has been:
1) to make R load first some packages whose functions are used in my function;
2) within my function, specifying the package to which each used function belongs (using the package::function() statement).

The above seems to have fixed the problem. I hope that that has not mixed up the functionality of other functions of my package :-/

Shoudl you have any further hint/suggestion, please let me know.
Last edited: