[R] summary with names

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Oct 16 13:53:08 CEST 2003


Christoph Bier wrote:
> Hi,
> 
> how can I tell 'summary' to print the name of the summarised variable? 
> This is probably an awkward newbie question but I didn't find an answer 
> in the Docus, the FAQ and maillist archive.
>    I want a summary for about 250 variables and realise it the following 
> way (I know, that I shouldn't use iterations that way in R; but at the 
> moment it's the easiest way for me):
> 
> for(i in fb.12.unt[varA1:varZ9]){print (summary(i, na.rm=t))}

Given fb.12.unt is a list or data.frame,
   lapply(fb.12.unt, summary, na.rm = TRUE)
or
   sapply(fb.12.unt, summary, na.rm = TRUE)
might do what you want.

BTW: "na.rm=t" is wrong anyway ...


Uwe Ligges


> It works fine, but I don't know which summary corresponds to which 
> variable, because the variable names are not printed. Can somebody give 
> me a hint?
> 
> TIA
> 
> Regards,
> 
> Christoph




More information about the R-help mailing list