built-in functions in r can used in formula objects, example
reg1 = lm(y ~ log(x), data = data1) how can write functions such can used in formula objects?
fnmyfun = function(x) { return(x^2) } reg2 = lm(y ~ fnmyfun(x), data = data1)
what you've got works. 1 problem different modelling functions handle formulas in different ways. think long return model.matrix can make sense of, you'll fine. mean
the function vectorised; ie given vector of length n, returns result of length n
it has return atomic vector or matrix (but not list, or of type
raw)
Comments
Post a Comment