latex - R xtable: Wrap overflowing columns into subtables -


this question related 1 here, feel solutions provided there don't answer question.

split xtable ouput sub tables

my question same. in r, have following aggregated data table:

> agg2        x1.err     x1.pct       x2.err     x2.pct       x3.err     x3.pct      x4.err     x4.pct        x5.err     x5.pct     x6.err 1 s.noun_noun 0.13121019  s.noun_noun 0.19791667  s.noun_noun 0.16730769 s.noun_noun 0.17659574  s.noun_noun 0.18352941 s.noun_noun 2 s.verb_verb 0.12611465  s.verb_verb 0.13750000  s.verb_verb 0.14615385 s.verb_verb 0.14042553  s.verb_verb 0.13176471 s.verb_verb 3   s.det_det 0.04076433    s.det_det 0.04375000    s.det_det 0.05384615 s.prep_prep 0.04042553 s.coord_prep 0.04000000 s.prep_prep 4 s.verb_noun 0.03821656    s.prn_prn 0.03958333 s.coord_prep 0.04423077   s.prn_prn 0.03829787    s.det_det 0.04000000   s.det_det 5  s.prep_det 0.03312102 s.coord_prep 0.03750000  s.prep_prep 0.04230769   s.det_det 0.03617021   s.prep_det 0.03764706   s.prn_prn       x6.pct      x7.err     x7.pct       x8.err     x8.pct 1 0.16839378 s.noun_noun 0.18330309  s.noun_noun 0.18281536 2 0.14766839 s.verb_verb 0.14700544  s.verb_verb 0.13893967 3 0.04663212   s.det_det 0.03811252   s.verb_prn 0.03839122 4 0.03886010   s.prn_prn 0.03448276  s.verb_noun 0.03656307 5 0.03108808 s.verb_prep 0.03448276 s.coord_prep 0.03473492 

displaying data frame in r overflows, won't fit in latex document. in example, can assume splitting 2 "subtables" 8 columns each fit on page.

 print(xtable(agg2, caption=my awesome caption,               label="tbl:mytable", digits=3)) 

how can force "table" 2 sub-tables 8 columns each? in other words, how can force output make n sub-tables maximum of k columns each? (n decided function, not user)

note: not want table printed sideways. , prevent over-complicating q&a, i'm not considering possibility table span multiple pages.

this no error checking, , have determine number of columns manually, should give starting point. edited produce sub-tables, understand it.

# define function takes 2 parameters: # - long data.frame  # - number of columns want print in 1 table vartable <- function( agg, cols )  {   tables <- ceiling( length( agg ) / cols )    # number of tables produce   # list, first element number of sub-tables   p <- list( tables )   # produce many table needed full number of columns   for( in 0 : ( tables - 2 ) ) p[[ + 2 ]] <- xtable( agg[ ( cols * + 1):( cols * + cols ) ] )   # last table may have less columns , takes caption   p[[ + 3 ]] <- xtable( agg[ ( cols * ( + 1  ) + 1):( length( agg ) ) ], caption = "bla" )   # return list xtable objects can printed 1 one   return( p ) } 

call function

aggs <- vartable( agg2, 6 ) 

and print altogether with

for( in 2 : ( aggs[[ 1 ]] + 1 ) ) print( aggs[[ ]], hline.after = 0 ) 

this gives me enter image description here


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -