在R中使用sprintf计算动态表达式
我正尝试在表达式求值之前通过以下方式动态创建表达式:在R中使用sprintf计算动态表达式,r,printf,R,Printf,我正尝试在表达式求值之前通过以下方式动态创建表达式: authors <- c("John1","John2") exp1 <- "(Author1==%s & Author2==%s)" 作者您可以使用: library(plyr) splat(sprintf)(c(exp1, authors)) 或没有图书馆: do.call(sprintf,as.list(c(exp1,authors))) 您可以使用以下选项: library(plyr) splat(sprin
authors <- c("John1","John2")
exp1 <- "(Author1==%s & Author2==%s)"
作者您可以使用:
library(plyr)
splat(sprintf)(c(exp1, authors))
或没有图书馆:
do.call(sprintf,as.list(c(exp1,authors)))
您可以使用以下选项:
library(plyr)
splat(sprintf)(c(exp1, authors))
或没有图书馆:
do.call(sprintf,as.list(c(exp1,authors)))