[R] abbreviate dataframe for Sweave output

stubben stubben at lanl.gov
Wed Feb 7 00:38:35 CET 2007


I wanted to print the first and last rows of some dataframes in Sweave 
using dots in columns to separate the two parts.  Head and tail almost 
work, but I have problems with factors and row names.

z<-data.frame(id=letters[1:26], x=sample(1:26,26))

rbind(head(z,3), ".", tail(z,1))

      id  x
1     a 18
2     b  8
3     c 14
4  <NA>  .
26    z 10
Warning message:
invalid factor level, NAs generated in...


I would like something like this if possible.  Any ideas?

      id  x
1     a 18
2     b  8
3     c 14
.     .  .
.     .  .
26    z 10


Thanks,

Chris Stubben



-- 
-----------------

Los Alamos National Lab
BioScience Division
MS M888
Los Alamos, NM 87545



More information about the R-help mailing list