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));

```
You will need some special handling to match these methods with primitive parameters with the corresponding boxed types.

A simple approach that might suffice is to create a mapping between the boxed and primitive types, and look for methods using both types. This is just a sketch:

```
    Map<Class<?>, Class<?>> boxedToPrimitive = new HashMap<>();
    boxedToPrimitive.put(Integer.class, Integer.TYPE);
    boxedToPrimitive.put(Long.class, Long.TYPE);
    boxedToPrimitive.put(Boolean.class, Boolean.TYPE);
    ...

    String name = getSetMethod(key);
    Method method;
    try {
        method = target.getClass().getMethod(name, val.getClass());
    } catch (NoSuchMethodException missing) {
        Class<?> alt = boxedToPrimitive.get(val.getClass());
        if (alt == null) throw missing;
        method = target.getClass().getMethod(name, alt);
    }
    method.invoke(target, value);

```