Processing
 

Table output to Word-2011 from Rstudio using knit

20/09/2016 17:28#1

Joined at: 5 months ago

Post: 3

Thank: 0

Thanked: 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

Similar articles

VBA regex matching over two lines

5 months ago - Reply: 1 - Views: 44

Table output to Word-2011 from Rstudio using knit

5 months ago - Reply: 0 - Views: 44

Write a Collection of paragraphs into a new document

5 months ago - Reply: 1 - Views: 72

how to write paragraphs without show to document

5 months ago - Reply: 1 - Views: 67

numericals in word macro

5 months ago - Reply: 1 - Views: 46

Can not find proofing tools

5 months ago - Reply: 0 - Views: 2

Possible values for <w:outlineLvl> in Word OOXML

5 months ago - Reply: 1 - Views: 8

C# restrict editing partial word paragraph

6 months ago - Reply: 2 - Views: 146

Macro translation Please (possible virus)

5 months ago - Reply: 1 - Views: 35

Doc/Docx Fastest Reading Method for Searching

5 months ago - Reply: 0 - Views: 3

Save embedded file / content from word

5 months ago - Reply: 0 - Views: 6

Counting words in Word document, including footnores

5 months ago - Reply: 1 - Views: 24

c# access extract word ole object

5 months ago - Reply: 1 - Views: 23

Using word wildcards to find unaccepted changes

5 months ago - Reply: 1 - Views: 46

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re