I was trying to shorten the process of passing the formula to the regsubsets() function instead of having to write the full string. So, I used the following code for generat