Dynamic “string” in R

后端 未结 4 2001
有刺的猬
有刺的猬 2020-11-28 16:27

Simple question, but cannot find the answer.

Instead of:

Df <- sqlQuery(ch, \"SELECT * FROM tblTest WHERE Id=25\")

I want a more

4条回答
  •  Happy的楠姐
    2020-11-28 17:24

    If you have multiple or reused arguments and a query that contains % you can use something like the following:

    sprintf("SELECT * FROM test WHERE id = %1$s AND name = %2$s and type like ‘%%tall%%’”, id, name)
    

提交回复
热议问题