I'm trying to help a colleague use loop and it occurred to me that it would be easier if we required less data pre-processing from the user. (Ideally it would be no harder than calling lm() in my opinion). So here's something:
Right now (I think), loop() only takes a matrix or a vector for Z
I think it would be easier for users if it also allowed data frames, like you could include a line like
if(is.data.frame(Z)) Z <- model.matrix(~.,data=Z)[,-1]
or something.
Even better would be if you could have an optional data argument to loop, and then allowed formulas. Then you could call it like:
I'm trying to help a colleague use loop and it occurred to me that it would be easier if we required less data pre-processing from the user. (Ideally it would be no harder than calling
lm()
in my opinion). So here's something:Right now (I think),
loop()
only takes a matrix or a vector forZ
I think it would be easier for users if it also allowed data frames, like you could include a line likeor something.
Even better would be if you could have an optional
data
argument toloop
, and then allowed formulas. Then you could call it like:or even just
where
posttest
,condition
,x1-x3
are columns ofdat