[Rd] sprintf limits output string length with no warning/error message

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Apr 21 12:23:20 CEST 2009

sprintf has a limit on the length of a string produced with a '%s'

   nchar(sprintf('%10000s', ''))
   # 8191

   nchar(sprintf('%*s', 10000, ''))
   # 8191

This is sort of documented in ?sprintf:

" There is a limit of 8192 bytes on elements of 'fmt' and also on
     strings included by a '%s' conversion specification."

but it should be a good idea for sprintf to at least warn when the
output is shorter than specified.


More information about the R-devel mailing list