Suppose I make a widget called foo and have a renderFoo() function. The correct way to use it in shiny is to call eg. renderFoo(foo(data)). But if it's a very simple widget that doesn't have many options and I just want to pass in data, I can easily forget that I'm supposed to call foo() and instead try to call
renderFoo(data)
When I do that, I get an error with a different unhelpful message depending on what the data is ("$ operator is invalid for atomic vectors" if it's a string, "object of type 'closure' is not subsettable" if it's a dataframe)
Good point @daattali. I think we can make renderFoo check whether the first argument being passed on to it is of the correct class, and if not, return an informative error message.
Suppose I make a widget called
foo
and have arenderFoo()
function. The correct way to use it in shiny is to call eg.renderFoo(foo(data))
. But if it's a very simple widget that doesn't have many options and I just want to pass in data, I can easily forget that I'm supposed to callfoo()
and instead try to callrenderFoo(data)
When I do that, I get an error with a different unhelpful message depending on what the data is ("$ operator is invalid for atomic vectors" if it's a string, "object of type 'closure' is not subsettable" if it's a dataframe)
I suspect this error stems from this innocent line: https://github.com/ramnathv/htmlwidgets/blob/master/R/htmlwidgets.R#L405
It's certainly not a bug in htmlwidgets, but I think it'd be better for the user , especially for beginners, to have a more informative error/check