Question: I have data frame `all_vars_ready_2016`. I what to apply `table` function with `exclude=NULL` argument to that data frame in order to get frequency tables of all variables of data frame. This works:

```
mapply(table, all_vars_ready_2016)

```

I tried to add `exclude=NULL` argument in several ways but non of them succeed. What is the proper way to do that?

Answer: 
If you have the option to add libraries. The library [commons-beanutils](http://commons.apache.org/proper/commons-beanutils/) can be used to handle beans and properties.

In your case you could do:

```
Method method = PropertyUtils.getReadMethod( new PropertyDescriptor(key, resultClass));

```
> 
> Can anyone tell me if there is an alternative way to generate this method which works for both the primitive and non-primitive types?
> 
> 
> 

You can't do that. You can't have **one** method object that works for `foo(int)` and `foo(Integer)`. Because those would be two different methods. 

The reason why the compiler allows you to call some `foo(Integer)` with `foo(5)` is because the compiler uses boxing to turn 5 into an Integer object, to then pass that. 

Remember: the compiler decides at compile time which method will be invoked. When there are two methods of the same name with different argument types, then that is **overloading** ... and happens at compile time.

Long story short: either you have to create **two** Method objects, or **you** have to provide the necessary code to box/unbox between primitive and boxed reference types as needed!