[R] add transformed columns into a matrix

Bjørn-Helge Mevik bhx2 at mevik.net
Tue Jun 28 13:12:27 CEST 2005


Supposing 'inmatrix' is a matrix with coloumn names 'x1', 'x2' and
'x3'; how about something like

model.matrix(~ (x1 + x2 + x3)^2 + log(x1) + log(x2) + log(x3) +
             sqrt(x1) + sqrt(x2) + sqrt(x3) - 1,
             as.data.frame(inmatrix))

-- 
Bjørn-Helge Mevik




More information about the R-help mailing list