Q:

R : mob (Model-based Recursive Partitioning) formula writing

I have the next R code:
mobTree <- mob(total_events ~ user_age |
             a + b + c + d + e + f + g + h,
             data = someData, 
             model = linearModel, control = mob_control(minsplit = 40))

in someData I have the following columns: 
unwanted1, unwanted2, total_events, user_age, a, b, c, d, e, f, g, h.

When I execute the command above, it works. because the formula:
total_events ~ user_age |
                 a + b + c + d + e + f + g + h,

is explicity mentioning that desirable columns
I want to make the same execution code but without mentioning the desirable columns, since on the fly it could be a - b or a -h or a - z. I dont know how many disirable columns will be or what thier names will be. What I do know is the names of the columns I dont want after the |.
So I've tried the following formulas:
total_events ~ user_age | . -unwanted1 -unwanted2
total_events ~ user_age | . -unwanted1 -unwanted2 -total_events
total_events ~ user_age | . -unwanted1 -unwanted2 -total_events -user_age
total_events ~ user_age | . -unwanted1 -unwanted2 -user_age

None of them worked.
I would be glad to know how to write the 2nd part of the formula (the a + .. + h that comes after the "|" mark) that will include all of someData columns without the unwanted ones

A:

If total_events ~ user_age is in someData u should use:
someData$total_events ~ someData$user_age | 

in data = someData, u will put a modification of the data which is changed as follows:
unwanted <- c("unwanted1", "unwanted2", "total_events", "user_age")
data = someData[, !colnames(someData) %in% unwanted]

meaning all columns mentioned in unwanted will be excluded from the data. this will result the following code:
unwanted <- c("unwanted1", "unwanted2", "total_events", "user_age")
mobTree <- mob(someData$total_events ~ someData$user_age | .,
             data = someData[, !colnames(someData) %in% unwanted], 
             model = linearModel, control = mob_control(minsplit = 40))

