formulr

formulr

This is a helper package used in rollply to handle formulas of the form a ~ b + c | d.

It converts this kind of formulas into a formulr object (actually a list) with three components, x,y and g (for groups) :

library(formulr)
form <- as.formulr(a ~ b + c | d)
str(form)

This object can then be eval'ed given some data and optionally an enclosing environment:

.dat <- data.frame(a=rnorm(10), 
                   b=runif(10), 
                   c=rpois(10,10), 
                   d=rbeta(10, 1, .5))
result <- eval.formulr(as.formulr(a ~ b + c | d), envir=.dat)
str(result)

This object can be then converted back to useful data structures:

df <- as.data.frame(result)
str(df)
df <- as.data.frame(result, collapse=TRUE)
round(df,digits=2)

Warning

formulr is still under heavy development and is mainly an externalisation of some tools needed by rollply rather than a full-blown package. It might turn into something more official one day though.

Use at your own risk.



Try the formulr package in your browser

Any scripts or data that you put into this service are public.

formulr documentation built on May 2, 2019, 6:52 p.m.