R数据表摘要

时间:2015-09-19 02:05:18

标签: r data.table

您如何显示相当短(~40)行数据表的简短压缩版本?我知道对于很长的数据表,它会自动显示这个缩短的版本,显示第一行和最后一行。但是,对于短数据表,它只显示整个数据表。有没有办法强迫短版本?

缩写版本示例:

         tpl       motif                 refName strand base score ipdRatio coverage
  1:    7098 ATCAAGGTCCT scf7180000000004|quiver      0    A    64    6.347       38
  2:   46246 ATCAATCGCCT scf7180000000004|quiver      0    A   213    6.371      148
  3:   57947 ATCATATTCCT scf7180000000004|quiver      0    A   226    6.464      147
  4:   59260 ATCAATTACCT scf7180000000004|quiver      0    A   203    5.715      120
  5:   72361 ATCATGTTCCT scf7180000000004|quiver      0    A   205    6.449      144
 ---                                                                                
537: 2835276 ATCATTTGCCT scf7180000000004|quiver      1    A   201    6.329      153
538: 2837973 ATCAATTGCCT scf7180000000004|quiver      1    A   215    5.982      146
539: 2842508 ATCAAATACCT scf7180000000004|quiver      1    A   196    4.241      157
540: 2844725 ATCGTACTCCT scf7180000000004|quiver      1    A   227    6.123      140
541: 2847076 ATCAGTACCCT scf7180000000004|quiver      1    A   158    5.990      120

1 个答案:

答案 0 :(得分:4)

如果您希望为10行或更多行的数据表显示“汇总”版本,请尝试<?php $num_records = mysql_num_rows($result); if (!isset($search)) $search = ""; ?> <table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"><tr><td> </td></tr></table> <table width="95%" align="center" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> <tr> <td width=25%> <?php if ($offset > 99) { echo '<a href='.$_SERVER['PHP_SELF'].'?$offset='.($offset-100).'>Previous 100</a>'; } else { echo 'Previous 100'; } ?> </td> <td align=center width=10%> <span class="content1"><a href=search.php>Search </a></span> </td> <td align=right width=25%> <?php if($num_records == 101) { echo '<a href="'.$_SERVER['PHP_SELF'].'?offset='.($offset+100) .$search.'">Next 100</a>'; } else { echo 'Next 100'; } ?> </td> </tr> </table> <table align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666" style="margin: 5px 15px; 5px 10px;"> <tr style="background: #9ae6f1; font-family: Verdana; font-weight: bold; font-size: 18px;"> <td style="width: 65%; padding: 5px;"> Video </td> <td align="center" style="width: 10%; padding: 5px;"> Guest Name </td> <td align="center" style="width: 10%; padding: 5px;"> Date </td> </tr> <?php $count = 1; $bgc = 1; while($row = mysql_fetch_array($result)) { if ($count > 100) break; echo '<tr style="background: '; if (($bgc == 0 ? $bgc=1 : $bgc=0) == 0) echo "#FFFFFF"; else echo "#E6E6E6"; echo ';">'; echo '<td><div style="padding: 3px;" class="content"><a href=../../watch/watch.php?ID='.$row[ID].'>'.$row[Title].'</a></div></td>'; echo '<td><div style="padding: 3px;" class="content">'.$row[GuestName].'</div></td>'; echo '<td><div align="center" style="padding: 3px;" class="content">'.$row[Publish_Date].'</div></td></tr>'; $count++; } ?> </table> <table width="95%" align="center" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> <tr> <td width=25%> <?php if($offset > 99) { echo '<span class="content"><a href='.$_SERVER['PHP_SELF'].'?offset='.($offset-100).$search.'>Previous 100</a></span>'; } else { echo 'Previous 100'; } ?> </td> <td align=center width=10%> <span class="content1"><a href=search.php>Search </a></span> </td> <td align=right width=25%> <?php if($num_records == 101) { echo '<span class="content"><a href='.$_SERVER['PHP_SELF'].'?offset='.($offset+100).$search.'>Next 100</a></span>'; } else { echo 'Next 100'; } ?> </td> </tr> </table>

该选项的默认值为50.在Data Table FAQ 2.11

中了解有关它的更多信息