The second part looks like a typical error, so just guessing that you haven't defined data or that you made a typo when you defined it. Better run ls() and class(data) to see if you have defined it and if it is of a class which is not a function. Then make sure to define your data object and it should run fine.
The issue arises, because data() is a name from a function from the utils package, which is always loaded by default. When you don't have a non function object called also data, R will try to apply the $ generic to the function data(), which gives the error, because there is no meaningful $ method for functions.
However, I am not sure why there is "runtime" in the error message. If my guess is not correct, I would also say, that one needs more information (best a reprex) to help here.