R, passing variables to a system command

后端 未结 2 1914
醉梦人生
醉梦人生 2021-01-02 23:20

Using R, I am looking to create a QR code and embed it into an Excel spreadsheet (hundreds of codes and spreadsheets). The obvious way seems to be to create a QR code using

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 00:16

    Let's say we have the variable x that we want to pass on to dmtxwrite, you can pass it on like:

    x = 10
    system(sprintf("dmtxwrite %s -o image.png", x))
    

    or alternatively using paste:

    system(paste("dmtxwrite", x, "-o image.png"))
    

    but I prefer sprintf in this case.

提交回复
热议问题