在为情节标题提供plotmath
表达式时,我认为它的paste
工作方式就像paste
,但现在我不确定。它是函数的特殊参数plotmath
吗?在 plotmath 中的paste()
行为类似于paste0()
并被paste0
直接引用,而 的sep
参数paste()
被忽略,但未在表达式中引用。是如何paste()
解释的?请参阅以下四个示例:
# Data to plot
x <- seq( 55 , 70 , length = 2001 )
probs <- dexp( x , rate = 5 / 60 )
s <- sample( x , 10000 , prob = probs , repl = TRUE )
# Some plots
par(mfrow = c(2,2) )
#1) paste() behaves like paste0() here
hist( s , breaks = 30 ,
main = expression( paste( "1: Sampling of" , Phi , "Distribution" ) ) ,
xlab = "No spaces in title using paste()" , axes = F )
#2) add spaces in the expression where they are needed
hist( s , breaks = 30 ,
main = expression( paste( "2: Sampling of " , Phi , " Distribution" ) ) ,
xlab = "Single spaces in titles: paste() behaves like paste0()" , axes = F )
#3) Don't put spaces, use a sep argument - ignored
hist( s , breaks = 30 ,
main = expression( paste( "3: Sampling of" , Phi , "Distribution" , sep = " " ) ) ,
xlab = "No spaces using paste(), `sep` argument is ignored but not quoted in expression" , axes = F )
#4) paste0 is not recognised
hist( s , breaks = 30 ,
main = expression( paste0( "4: Sampling of " , Phi , " Distribution" ) ) ,
xlab = "paste0() not recognised" , axes = F )