Try this:
 mod = lm(methcol ~ exposure+X1+X2+X3+batch, data = meth_matrix)
res=coef(summary(mod))[2,]

It will good if you give a subset of data you are working on by dput.

Raghu


On Sat, Jul 12, 2014 at 3:11 PM, Jessica Timms <j.a.timms@newcastle.ac.uk>
wrote:

> Hi,
>
>
>
> I'm quite new to R and currently trying to use lm to fit linear models but
> I am currently stuck my code is as follows:
>
>
>
> Model1 = function(meth_matrix,exposure, X1, X2, X3, batch) {
>
>   mod = lm(meth_matrix[, methcol]~exposure+X1+X2+X3+batch)
>
>   res = summary(mod)$coef[2,]
>
>
>
> system.time(indiv.results <-  mclapply(setNames(ncol=473864(cord_betas)),
> dimnames(cord_betas)[[2]]), Model1, meth_matrix=cord_betas,
> exposure=filtered_pheno, X1=covariates$k032, X2=covariates$k021,
> X3=covariates$kz029, batch=pdata.B1221.cord$BCDPlate))
>
>
> }
>
>
>
> I am not sure if this will make any sense or if you need any more
> information?
>
> Any help or guidance would be massively appreciated.
>
>
>
> Best wishes
>
>
>
> Jessica Timms
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

