[R] Printing column names before each block of output

A Singh Aditi.Singh at bristol.ac.uk
Mon Sep 21 14:15:16 CEST 2009


Dear All,

I need to print the column names of variables before each block of output, 
for a nested model with 2 levels (3 phenotypes * 10 markers).
This is so that my output is labeled, and I know which combination of 
factors produces which set of REML estimates.

Currently my output looks like this:

[1] "Phenotype"
NULL                ##this is where I want to insert colnames OR numbers 1-3
[1] "Marker"
NULL                  ##insert colnames again OR numbers 1-10
Linear mixed model fit by REML
- (data)
- (data)
Random effects:
-(data)
.
.
[1] "Marker"
NULL
Linear mixed model fit by REML
- (data)
- (data)
Random effects:
.
.
(3*10 combinations)


My code is as follows:

vc<-read.table("...",header=T)
vcdf<-data.frame(vc)
vcdf[2:13]<-lapply(vcdf[2:13,factor)
colms<-(vcdf)[4:13] ## these are the 10 markers. I put them in a new 
variable to make running the loop simple.

phen<-(vcdf)[14:16] ##these are the 3 phenotypes

for( c in phen)
{
print("Phenotype")
print(colnames(c))
for( f in colms)
{
print("Marker")
print(colnames(f))
fit<-lmer(data=vcdf, c~1 + (1|family/f))
print(summary(fit))
}}

Any pointers on how to print either column names, or a sequence of numbers?

Thanks a lot for your help,

Aditi





----------------------
A Singh
Aditi.Singh at bristol.ac.uk
School of Biological Sciences
University of Bristol




More information about the R-help mailing list