R 如何避免使用data.table打印行号?
打印R 如何避免使用data.table打印行号?,r,data.table,R,Data.table,打印数据。表在实际输出之前为每行输出添加一个数字,例如: > DT <- data.table(cbind(1:3,3:1)) > DT V1 V2 1: 1 3 2: 2 2 3: 3 1 > print(DT) V1 V2 1: 1 3 2: 2 2 3: 3 1 >DT V1 V2 1: 1 3 2: 2 2 3: 3 1 >打印(DT) V1 V2 1: 1 3 2: 2 2 3: 3
数据。表
在实际输出之前为每行输出添加一个数字,例如:
> DT <- data.table(cbind(1:3,3:1))
> DT
V1 V2
1: 1 3
2: 2 2
3: 3 1
> print(DT)
V1 V2
1: 1 3
2: 2 2
3: 3 1
>DT
V1 V2
1: 1 3
2: 2 2
3: 3 1
>打印(DT)
V1 V2
1: 1 3
2: 2 2
3: 3 1
如何避免在数据行之前打印“1:”、“2:”、“3:?我想使用
xtable
print.data.table
编写html格式或latex格式的数据输出。table有一个参数row.names
,默认设置为TRUE。只用
> print(DT, row.names=FALSE)
V1 V2
1 3
2 2
3 1
如果要在
xtable()
output中禁止使用名称,则需要使用
print.xtable()
的参数:
库(xtable)
df当我想进一步处理data.table时,例如在xtable(DT)
中,是否还有一种方法可以去除行名?
library(xtable)
df <- data.frame(x = 1:3, y = 3:1)
xtable(df)
## % latex table generated in R 3.0.2 by xtable 1.7-1 package
## % Wed Apr 9 06:53:55 2014
## \begin{table}[ht]
## \centering
## \begin{tabular}{rrr}
## \hline
## & x & y \\
## \hline
## 1 & 1 & 3 \\
## 2 & 2 & 2 \\
## 3 & 3 & 1 \\
## \hline
## \end{tabular}
## \end{table}
print(xtable(df), include.rownames = FALSE)
## % latex table generated in R 3.0.2 by xtable 1.7-1 package
## % Wed Apr 9 06:53:55 2014
## \begin{table}[ht]
## \centering
## \begin{tabular}{rr}
## \hline
## x & y \\
## \hline
## 1 & 3 \\
## 2 & 2 \\
## 3 & 1 \\
## \hline
## \end{tabular}
## \end{table}