Error: attempt to apply non-function

I am running this basic function using Mongolite and a plumber script and this just doesn't seem to work:

training_status <- training_status$find(query = '{"TrainingStatus" : "running"}')

It is giving me the following error repeatedly:
Error: attempt to apply non-function

I don't understand the reason behind this. All other functions seem to be working fine. Why does this error occur anyway?

The key to tracking this down is to look for (, which is a giveaway that a function is getting ready to take its argument. So, just look left and see

training_status$find

which is pretty sure to be a column in a data frame, rather than a function.

1 Like

I actually was able to trace my error somewhat.

Earlier, I had:
training_status <- training_status$find(query = '{"TrainingStatus" : "running"}')

I made the variable 'training_status' with the same name as the connection object of the MongoDB server. So I ran my plumber script, it didn't find training_status$find
I changed the variable name in plumber script to say, status and it worked then.

Thanks for your help, though! :grinning:

1 Like

There might be a better way of handling off to mongo than a string disguised as an R function

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.