Table output to Word-2011 from Rstudio using knit

ساخت وبلاگ

Vote count: 0

Trying to simply generate report ready tables JFT or monthly frequency summary tables in Word-2011 from Rstudio using knit from OSX. The archives suggest various solutions, such as HTML and asis, pandoc ( How to present a nice looking frequency table from R in MS Word), etc. All fail. For instance, the sample at the link above is nicely formatted with the variable names. The variable names are lost when I run the same code and the formatting is lost when knitted to in Word. Screenshots of the two cases are attached.

The tables generated from the following code look respectable in fixed font on in Rstudio or R (look at output of jft.r if run on its own) but fail when knitted from jft.RMD which is the reason for the question on templates posted earlier.

JFT.RMD ---
title: "Untitled"
output: word_document
---
# Code Externalization
generate JFT and for export to word.
```{r cache=FALSE}
library(openair)
library(lubridate)
library(printr)
library(plyr)
library(knitr)
library(pander)
options(scipen=999)
mod = function(degrees,base) { results = degrees %% base return(results)
}
dirBIN = function(dir,bins) { mod(round_any(x=dir+bins/2,bins,f=floor),360)
}
knitr::read_chunk('jft.R')
```
The followingchunks is from the external R script `jft.R`:
```{r test-a, echo=F}
```
### JFT.R
library(openair)
library(lubridate)
library(printr)
library(plyr)
library(knitr)
library(pander)
options(scipen=999)
mod = function(degrees,base) { results = degrees %% base return(results)
}
dirBIN = function(dir,bins) { mod(round_any(x=dir+bins/2,bins,f=floor),360)
}
# ---- test-a ----
InputTS = mydata
InputTS$spdBin = round_any(x=InputTS$ws,1.25,ceiling)
InputTS$dirBIN = dirBIN(InputTS$wd,45)
InputTS$mm = month(InputTS$date)
FreqByMM = table(InputTS$spdBin,InputTS$mm,dnn=c("SPD","Month"))
# Tabulate freq by month
FRQByMM = prop.table(FreqByMM,2)
ByMMout = addmargins(FRQByMM)
ByMMout = subset(ByMMout,select=-c(13))
options(digits=2)
ByMMout
knitr::kable(ByMMout,format='pandoc',caption ='pd2')

enter image description here

asked 44 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : output table to pdf in r,output table to csv sql,output table to excel in r,stata table output to excel,pivot table output to multiple sheets,format,table output to file,powershell table output to csv,powershell table output to file,mysql table output to file,powershell table output to array, نویسنده : استخدام کار backsoft بازدید : 408 تاريخ : سه شنبه 30 شهريور 1395 ساعت: 13:14