Hello R users,
 
I'm trying to solve an apparently simple problem.
I include a matrix in a model formula, and I want then to extract the related coefficients.
Basically, I want a function func such that:
 
mymatrix <- cbind(rnorm(10),rnorm(10))
y <- b <- rnorm(10)
model <- lm(y ~ b + mymatrix)
func(mymatrix,model)
 
which returns only the 3rd and 4th coefficients.
 
I thought to search by:
 
grep("mymatrix",names(coef(model)))
 
but I don't know how to extract the name "mymatrix" from the object mymatrix.
Is there a specific function, something like func(mymatrix) returning the string "mymatrix"?
 
Thanks so much for your time.
 
Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU)
London School of Hygiene & Tropical Medicine
Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
Skype contact: a.gasparrini
http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ )

	[[alternative HTML version deleted]]


