I have a long table;
long_table <- structure(list(species = c("ABIBAL", "ACEPEN", "ACERUB", "ACESAC",
"ACESPI", "ARANUD", "ARITRI", "ATHANG", "BETALL", "CARARC", "CARINT",
"CINLAT", "CLIBOR", "DENPUN", "DRYCAM", "DRYINT", "FAGGRA", "FRAAME",
"HUPLUC", "LONCAN", "MAICAN", "MAIRAC", "MEDVIR", "NABSPP", "OCLACU",
"OXAMON", "PARNOV", "PHECON", "PICRUB", "RUBIDA", "SAMRAC", "STRAMP",
"TIACOR", "TRIBOR", "TRIERE", "TRIUND", "TSUCAN", "UVUSES", "VIBLAN",
"VIOBLA", "VIOROT"), all_3 = c(0.805, 0.84, 0.682, 0.764, 0.783,
0.828, 0.799, 0.765, 0.704, 0.782, 0.771, 0.799, 0.733, 0.694,
0.658, 0.82, 0.821, 0.766, 0.742, 0.721, 0.793, 0.782, 0.755,
0.738, 0.62, 0.753, 0.711, 0.736, 0.657, 0.694, 0.769, 0.664,
0.77, 0.735, 0.83, 0.709, 0.785, 0.749, 0.827, 0.744, 0.799),
topo_spectral_3 = c(0.729, 0.729, 0.592, 0.762, 0.668, 0.735,
0.736, 0.758, 0.626, 0.782, 0.589, 0.649, 0.753, 0.647, 0.633,
0.833, 0.821, 0.717, 0.667, 0.591, 0.76, 0.747, 0.699, 0.652,
0.522, 0.531, 0.696, 0.708, 0.704, 0.675, 0.739, 0.673, 0.678,
0.697, 0.705, 0.683, 0.717, 0.748, 0.725, 0.676, 0.793),
default = c(0.701, 0.553, 0.628, 0.605, 0.565, 0, 0.601,
0.574, 0, 0.5, 0, 0.566, 0, 0.544, 0.58, 0.582, 0.614, 0.5,
0.649, 0, 0, 0.465, 0.585, 0.528, 0, 0.619, 0.486, 0.536,
0.49, 0.586, 0.704, 0, 0.564, 0, 0.528, 0.556, 0, 0.497,
0, 0.533, 0.586)), row.names = c(NA, -41L), class = "data.frame")
I am preparing it for publication and want the whole table to be viewable without scrolling. The most apparent solution to me is to double the columns and hence cut the length in half.
I see this type of thing discussed in the LaTex community ( https://tex.stackexchange.com/questions/134381/dealing-with-very-long-table-split-into-columns ) but have not seen documentation for how to do this using R.
Image from the above link;
How can I make publication quality tables with double width as seen in the above image using R?
That's easy using xtable
:
xtable::xtable(long_table)
This code prints you LaTeX code to the console which you may copy into an Rmarkdown file. Don't put it into a code junk, put it just as normal text. Then just apply the instructions you shared in your question and insert some lines with the points to make the panels of equal length.
---
output: pdf_document
classoption:
- a4paper
- landscape
---
<!-- suppress page numbers -->
\pagenumbering{gobble}
\begin{table}[ht]
\centering
\begin{tabular}{rlrrr}
\hline
& species & all\_3 & topo\_spectral\_3 & default \\
\hline
1 & ABIBAL & 0.80 & 0.73 & 0.70 \\
2 & ACEPEN & 0.84 & 0.73 & 0.55 \\
3 & ACERUB & 0.68 & 0.59 & 0.63 \\
4 & ACESAC & 0.76 & 0.76 & 0.60 \\
5 & ACESPI & 0.78 & 0.67 & 0.56 \\
6 & ARANUD & 0.83 & 0.73 & 0.00 \\
7 & ARITRI & 0.80 & 0.74 & 0.60 \\
8 & ATHANG & 0.76 & 0.76 & 0.57 \\
9 & BETALL & 0.70 & 0.63 & 0.00 \\
10 & CARARC & 0.78 & 0.78 & 0.50 \\
11 & CARINT & 0.77 & 0.59 & 0.00 \\
12 & CINLAT & 0.80 & 0.65 & 0.57 \\
13 & CLIBOR & 0.73 & 0.75 & 0.00 \\
14 & DENPUN & 0.69 & 0.65 & 0.54 \\
15 & DRYCAM & 0.66 & 0.63 & 0.58 \\
16 & DRYINT & 0.82 & 0.83 & 0.58 \\
17 & FAGGRA & 0.82 & 0.82 & 0.61 \\
18 & FRAAME & 0.77 & 0.72 & 0.50 \\
19 & HUPLUC & 0.74 & 0.67 & 0.65 \\
20 & LONCAN & 0.72 & 0.59 & 0.00 \\
. & . & . & . & . \\
. & . & . & . & . \\
. & . & . & . & . \\
\hline
\end{tabular}
\begin{tabular}{rlrrr}
\hline
& species & all\_3 & topo\_spectral\_3 & default \\
\hline
. & . & . & . & . \\
. & . & . & . & . \\
21 & MAICAN & 0.79 & 0.76 & 0.00 \\
22 & MAIRAC & 0.78 & 0.75 & 0.46 \\
23 & MEDVIR & 0.76 & 0.70 & 0.58 \\
24 & NABSPP & 0.74 & 0.65 & 0.53 \\
25 & OCLACU & 0.62 & 0.52 & 0.00 \\
26 & OXAMON & 0.75 & 0.53 & 0.62 \\
27 & PARNOV & 0.71 & 0.70 & 0.49 \\
28 & PHECON & 0.74 & 0.71 & 0.54 \\
29 & PICRUB & 0.66 & 0.70 & 0.49 \\
30 & RUBIDA & 0.69 & 0.68 & 0.59 \\
31 & SAMRAC & 0.77 & 0.74 & 0.70 \\
32 & STRAMP & 0.66 & 0.67 & 0.00 \\
33 & TIACOR & 0.77 & 0.68 & 0.56 \\
34 & TRIBOR & 0.73 & 0.70 & 0.00 \\
35 & TRIERE & 0.83 & 0.70 & 0.53 \\
36 & TRIUND & 0.71 & 0.68 & 0.56 \\
37 & TSUCAN & 0.78 & 0.72 & 0.00 \\
38 & UVUSES & 0.75 & 0.75 & 0.50 \\
39 & VIBLAN & 0.83 & 0.72 & 0.00 \\
40 & VIOBLA & 0.74 & 0.68 & 0.53 \\
41 & VIOROT & 0.80 & 0.79 & 0.59 \\
\hline
\end{tabular}
\end{table}
You may want to look into the booktabs
LaTeX package with which you can draw nicer lines using toprule, midrule, bottomrule
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.