我有一个已分配给变量的整数,我想将它打印到控制台但我收到错误。下面的代码和示例
number <- 64
print("I want to print this number: " + number)
但我收到消息:“错误:二元运算符的非数字参数” 我希望看到像
这样的东西[1] "I want to print this number: 64"
答案 0 :(得分:3)
使用sprintf
sprintf("I want to print this number: %i", number)
#[1] "I want to print this number: 64"
或paste0
paste0("I want to print this number: ", number)
#[1] "I want to print this number: 64"