我嘗試使用粘貼函式列印一些字串,以及 R 中的數字,例如:
method = "binomial"
b = 5
paste("The method is", a, "and the value is", b, ".")
結果看起來像
"The method is binomial and the result is 5 ."
如何洗掉 5 和 . 之間的空格?我希望結果看起來像
"The method is binomial and the value is 5."
如果我使用 paste0("The method is", a, "and the value is", b, ".") 結果看起來像
"The method isbinomialand the result is5."
謝謝你。
uj5u.com熱心網友回復:
使用paste0:
paste0("The values are ", a, " and ", b, ".")
"The values are 4 and 5."
或者 paste("The values are ", a, " and ", b, ".", sep = "")
uj5u.com熱心網友回復:
Paste0(...)或paste(..., sep = "")作業正常,但我發現glue()提供了一種連接字串的干凈方式,沒有大量的開始和結束引號。
在這種情況下:
glue::glue("The values are {a} and {b}.")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/412381.html
標籤:
上一篇:將Herfindahl-Hirschman索引函式應用于R中個人的一組行
下一篇:SML埃拉托色尼篩
