Dear all, I'm updating a package regarding a new type of models, and I'm looking to extend the formula interface with two functions (L() and R() ) for construction of these models. I want to use as much of the formula interface as possible, and hoped to do something similarly to I(). I know the I() function does nothing more than add the class "AsIs". I've been browsing the source code of R for a couple of days now trying to locate where this class assignment gets translated into a specific action, but i couldn't locate it. I've been as far as the internal C function modelframe. Any pointers on how I() is processed internally are greatly appreciated. Cheers Joris -- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Mathematical Modelling, Statistics and Bio-Informatics tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]]
Joris, Basically, the I() function, as it is used in a regression model, allows the user to perform arithmetic operations on a variable that would otherwise be interpreted by the formula. It is not trapped as a special function as Error() is in aov(). There may be other applications where the class "AsIs" is needed, so there are support functions for subscripting, formatting, printing and so forth. Dave On Fri, Oct 3, 2014 at 7:32 AM, Joris Meys <jorismeys at gmail.com> wrote:> Dear all, > > I'm updating a package regarding a new type of models, and I'm looking to > extend the formula interface with two functions (L() and R() ) for > construction of these models. I want to use as much of the formula > interface as possible, and hoped to do something similarly to I(). > > I know the I() function does nothing more than add the class "AsIs". I've > been browsing the source code of R for a couple of days now trying to > locate where this class assignment gets translated into a specific action, > but i couldn't locate it. I've been as far as the internal C function > modelframe. > > Any pointers on how I() is processed internally are greatly appreciated. > > Cheers > Joris > > -- > Joris Meys > Statistical consultant > > Ghent University > Faculty of Bioscience Engineering > Department of Mathematical Modelling, Statistics and Bio-Informatics > > tel : +32 9 264 59 87 > Joris.Meys at Ugent.be > ------------------------------- > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]
On 03 Oct 2014, at 14:32 , Joris Meys <jorismeys at gmail.com> wrote:> Dear all, > > I'm updating a package regarding a new type of models, and I'm looking to > extend the formula interface with two functions (L() and R() ) for > construction of these models. I want to use as much of the formula > interface as possible, and hoped to do something similarly to I(). > > I know the I() function does nothing more than add the class "AsIs". I've > been browsing the source code of R for a couple of days now trying to > locate where this class assignment gets translated into a specific action, > but i couldn't locate it. I've been as far as the internal C function > modelframe. > > Any pointers on how I() is processed internally are greatly appreciated.It isn't...> E <- function(x)x > x <- rnorm(10) > y <- rnorm(10) > lm(y~x+E(x^2))Call: lm(formula = y ~ x + E(x^2)) Coefficients: (Intercept) x E(x^2) 0.2757 0.1725 -0.3823 The point is that special interpretation of operators never happens inside function calls. I() is just a convenient do-nothing function call. If you want to add special operators, one place to look is in the handling of specials for survival::coxph.> > Cheers > Joris > > -- > Joris Meys > Statistical consultant > > Ghent University > Faculty of Bioscience Engineering > Department of Mathematical Modelling, Statistics and Bio-Informatics > > tel : +32 9 264 59 87 > Joris.Meys at Ugent.be > ------------------------------- > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Apparently Analagous Threads
- Most efficient way to check the length of a variable mentioned in a formula.
- Warning message when items of Hmisc are masked by loading a package.
- `[` not recognized as a primitive in certain cases.
- The use of match.fun
- weighted.median function from package R.basic