rms-worddesctools

Save and close a word document by giving a name in R


I am trying to use two libraries (DescsTool, R2wd) in order to get descriptive analysis of a dataset saved in a folder for exploration later. These are the steps I am trying

library(DescTools)
library(R2wd)
data(iris)

i <- ls()    
wrd <- GetNewWrd(header=TRUE)
wdGet()
Desc(get(i), plotit=TRUE, wrd=wrd)

wdSave(Name="temp.doc", wdapp=.R2wd)
wdQuit()

Although word is capturing output as supposed to be, I cannot save the word file giving a name (e.g.: temp.doc). Can someone shed some light here?


Solution

  • try

    library(DescTools)
    wrd <- GetNewWrd()
    Desc(iris, wrd=wrd)
    
    wrd[["ActiveDocument"]]$SaveAs2(FileName="Describe iris.docx")
    wrd$Quit()