xtable caption stays below

Sander Van der Zeeuw picture Sander Van der Zeeuw · Jul 15, 2013 · Viewed 8.1k times · Source

I created a table with the following Rsweave code.

<<fig=FALSE,results=tex ,echo=FALSE>>=
require('xtable')
res.table<-xtable(myfamDF, caption = 'Paired t-test of most common TF families', caption.placement="top", display = c('f','s','e','e','e','d','f','f','f'), table.placement="")

print(res.table, scalebox=0.7)

@

as one can see, i use the code caption.placement='top', but this does not work. I keep getting my caption below the table. What is going wrong? i tried to place the command before caption as well but still not works.

My table data:

structure(list(X = c("ETS", "FH", "HLH", "HMG", "Homeo", "Homeo ", 
"Homeo, POU", "IRF", "unknown", "Zn2Cys6", "ZnF_C2H2", "ZnF_C4"
), MASHvstRap = c(7.57756175712832e-05, 2.16501764489381e-05, 
1.28838720843028e-05, 7.61948145586808e-26, 2.60621688448055e-53, 
5.65846675050138e-11, 2.8351421540276e-06, 2.16501764489381e-05, 
3.2934292268274e-24, 2.82352692734938e-05, 6.64390583188061e-16, 
1.0825088224469e-05), MASHvsBEEML = c(0.000205676676264912, 0.00519604234774513, 
0.00724381285695056, 0.864846903741683, 5.63594927321681e-06, 
0.212004750633662, 0.519032309279987, 0.0114962436943861, 0.0364539615325715, 
0.00226912148014415, 0.00150554384087195, 0.165493948775683), 
    tRapvsBEEML = c(1.0825088224469e-05, 1.0825088224469e-05, 
    5.2304674730304e-05, 3.24328889627148e-13, 8.6852178695266e-46, 
    7.60650709869649e-06, 2.8351421540276e-06, 1.0825088224469e-05, 
    1.35923430631341e-18, 1.03873566123765e-06, 4.36897483629527e-17, 
    1.0825088224469e-05), frequency = c(10L, 10L, 13L, 44L, 158L, 
    19L, 11L, 10L, 121L, 17L, 54L, 10L), Mash_mean = c(0.524697080582274, 
    0.533031100926345, 0.612272921172441, 0.554248028314286, 
    0.718880708100701, 0.669975051155167, 0.689738366117961, 
    0.523671096430599, 0.441776560865089, 0.379363597547222, 
    0.549419213423343, 0.662304821003215), BEEML_mean = c(0.666798180226875, 
    0.660863667642578, 0.744265111335818, 0.475324697683268, 
    0.730669935762911, 0.650768612120795, 0.704779617351813, 
    0.623826799121585, 0.487316361691942, 0.608017794324143, 
    0.637626824316619, 0.732392229673044), tRap_mean = c(0.297319284507052, 
    0.270211650098443, 0.261921495552034, 0.124938264266261, 
    0.171602908725421, 0.138827064266711, 0.180368231533709, 
    0.279573714498502, 0.162194901674355, 0.127782526341284, 
    0.249250520527459, 0.274929655041024)), .Names = c("X", "MASHvstRap", 
"MASHvsBEEML", "tRapvsBEEML", "frequency", "Mash_mean", "BEEML_mean", 
"tRap_mean"), class = "data.frame", row.names = c(NA, -12L))

Answer

Roman Luštrik picture Roman Luštrik · Jul 15, 2013

You should specify caption.placement in print call, not xtable.

res.table<-xtable(myfamDF, caption = 'Paired t-test of most common TF families', 
                           display = c('f','s','e','e','e','d','f','f','f'), 
                   table.placement ="")

print(res.table, scalebox=0.7, caption.placement = "top")