2016-09-06 6 views
1

を表ノートの変更バージョンを追加し、私は、ダイナミックなレポートを生成するRはSweaveを使用していて、コードは次のとおりです。私が入れて注意する必要がが自動的に少し問題のためのあなたの助けを必要とRはSweaveで

industryTable<-data.frame("Industry" = INDUSTRY.DATA[1:15,]$industryname, 
         "Freq" = INDUSTRY.DATA[1:15,]$Freq, 
         "Perc" = INDUSTRY.DATA[1:15,]$Perc, 
         "Industry" = INDUSTRY.DATA[16:30,]$industryname, 
         "Freq" = INDUSTRY.DATA[16:30,]$Freq, 
         "Perc" = INDUSTRY.DATA[16:30,]$Perc) 
names(industryTable)<-c("Industry", "Freq","Perc","Industry", "Freq","Perc") 
add.to.row <- list(pos = list(nrow(industryTable)), command = NULL) 
comm <- paste0("\\hline \n \\multicolumn{",dim(industryTable)[2],"}{l}", 
       "{\\scriptsize{Matching-Method:Pscore, Base-Year:0,Matching-Interval:0.9-1.10,Log:T,Trim:F}} \n") 
add.to.row$command <-comm 
print(xtable(industryTable,caption = "Distribution of Privatization Across Manufacturing", label = "table:industry",align = c("c","p{4.5cm}","c","c","|p{4.5cm}","c","c"),digits = c(0,0,0,2,0,0,2)),caption.placement="top", include.rownames = FALSE,add.to.row = add.to.row,hline.after=c(-1, 0)) 

テーブルの下には、私が」は現在やって、私は、データの組み合わせの各32のバージョン7つのテーブルを持っている、しかし、それは正常に動作しますadd.to.row

add.to.row <- list(pos = list(nrow(industryTable)), command = NULL) 
    comm <- paste0("\\hline \n \\multicolumn{",dim(industryTable)[2],"}{l}", 
        "{\\scriptsize{Matching-Method:Pscore, Base-Year:0,Matching-Interval:0.9-1.10,Log:T,Trim:F}} \n") 

を使用しているまったく同じノート形式等は必ずしもここのもの、テーブルの内容とフォーマットは異なりますが、与えられたデータの櫛の7つのテーブルテーブルノートはまったく同じです。これは「マッチング方法:Pscore、基準年:0、マッチング間隔:0.9-1.10、ログ:T、トリム:F」です。これを実現する便利な方法はありますかコピー貼りがないと、面倒で危険です。

答えて

0

なぜ機能を作成しないのですか?あなたの応答@csgillespieため

make_table <- function(industryTable) { 
    l = list(pos = list(nrow(industryTable)), command = NULL) 
    comm <- paste0("\\hline \n \\multicolumn{",dim(industryTable)[2],"}{l}", 
        "{\\scriptsize{Matching-Method:Pscore, Base-Year:0,Matching-Interval:0.9-1.10,Log:T,Trim:F}} \n") 
    l$command <-comm 
    xtable(industryTable, 
      caption = "Distribution of Privatization Across Manufacturing", 
      label = "table:industry",align = c("c","p{4.5cm}","c","c","|p{4.5cm}","c","c"),digits = c(0,0,0,2,0,0,2)), 
      caption.placement="top", 
      include.rownames = FALSE, 
      add.to.row = l, hline.after=c(-1, 0) 
} 

ので

print(make_table(industryTable)) 
+0

おかげで、これはナットにそれを考えるための良い方法です。あいまいなため申し訳ありませんが、私の質問の説明、私が欲しいものではないよ、私は右のそれを修正します今、助けてください。 –

関連する問題