2

I get warning messages in the officer package after adding more than exactly 100 slides.

library(officer)
pres = read_pptx(path = NULL)
for (i in 1:100)
{
    print(i)
    pres <- add_slide( x = pres , layout = "Title Only", master = "Office Theme" )
}

The warning message is:

Warning message:
In x$slide$add_slide(xml_file, x$slideLayouts$get_xfrm_data()) :
  NAs introduced by coercion

No warning message would be generated if I limit the number of slides to 99 i.e. with

library(officer)
pres = read_pptx(path = NULL)
for (i in 1:99)
{
    print(i)
    pres <- add_slide( x = pres , layout = "Title Only", master = "Office Theme" )
}

the warning is not shown.

Is there some limit on the number of slides one can add in the officer package? And, if so, is there a way to fix this is since I need to generate over 100 slides to store data together.

Could not find this in the documentation. The above was tested with officer_0.4.1 on Windows 11 R4.1.1.

Jan Bos
  • 71
  • 2
  • 5
  • 1
    There's [no obvious 100 slide limit](https://github.com/davidgohel/officer/blob/master/R/pptx_slide_manip.R) in the add_slide code, but something in the warning suggests your xml_file needs to be as long/many as the slides you anticipate to `$get_xfrm_data()`. Will viewers be tied to chairs for the subsequent presentation? – Chris Mar 10 '22 at 03:36
  • @Chris It seems the add_slide function is accessing some local xml file. Not sure how I can control its size though. – Jan Bos Mar 10 '22 at 11:54
  • 1
    I cannot replicate this error. I don't get any warning message when running the above code. I tried with 300 just to be sure. Tested with `officer_0.4.1` on Windows 10 R 4.1.1 – MrFlick Mar 23 '22 at 03:34
  • I find out if I restart RStudio and run it the problem goes away - but it will reappear. Maybe some interaction with another package or something my other code - no idea. – Jan Bos Mar 24 '22 at 06:24
  • There is some example code, perhaps you used it without adjusting? https://github.com/davidgohel/officer/blob/ed805468388b4841f150f09c2efb88f76da10d90/R/read_docx.R#L26 – David Mar 29 '22 at 15:40

0 Answers0