1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rのxtableで列の位置をすべてセンタリングしてtexに出力

Posted at

大した話ではないけど、よく忘れるのでメモ。
テーブルをtexに出力する関数を作成しておくと後で便利なので、ある程度汎用的に使えるものを作成。
xtableで作成したテーブルの列数を数えて、その分、"c"をalignに追加する。
pasteではうまくいかない。

temp.r
tbl_pdfout <- function(x,y,z){
	 n <- ncol(x)
	 nalign <- paste0("l", paste0(rep("c",n),collapse=""), collapse="")
	 xtbl <- xtable(x, align=nalign, caption=y)
	 print(xtbl, floating.environment='sidewaystable', file=z)
	 return(x)
}
1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?