Skip to content

a little bug for the function 'sprintf' (PR#14161)

1 message · Petr Savicky

#
The function sprintf() produces a string, which is then printed
using R formatting. You probably expected the following.

  > cat(sprintf("%s is %f feet tall\n", "Sven", 7.1))
  Sven is 7.100000 feet tall

Compare also 

  > s <- sprintf("%s is %f feet tall\n", "Sven", 7.1)
  > cat(s)
  Sven is 7.100000 feet tall
  > print(s)
  [1] "Sven is 7.100000 feet tall\n"
  > 

PS.