gpt4 book ai didi

r - 粘贴是绘图数学表达式中的特殊参数吗?

转载 作者:行者123 更新时间:2023-12-02 02:42:38 24 4
gpt4 key购买 nike

当提供plotmath时表达情节标题我认为 paste就像 paste 一样工作,但现在我不确定。这是 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 )

enter image description here

最佳答案

确实paste在plotmath中不是经典paste 。请参阅?plotmath :

paste(x, y, z) juxtapose x, y, and z

pasteplotmath的背景下没有sep论证。

并且在源代码中plotmath.c你可以看到paste被重新定义:

/*----------------------------------------------------------------------
*
* Code for Concatenate Expressions
*
*/

static int ConcatenateAtom(SEXP expr)
{
return NameAtom(expr) && NameMatch(expr, "paste");
}

static BBOX RenderConcatenate(SEXP expr, int draw, mathContext *mc,
pGEcontext gc, pGEDevDesc dd)
{
BBOX bbox = NullBBox();
int i, n;

expr = CDR(expr);
n = length(expr);

for (i = 0; i < n; i++) {
bbox = CombineBBoxes(bbox, RenderElement(CAR(expr), draw, mc, gc, dd));
if (i != n - 1)
bbox = RenderItalicCorr(bbox, draw, mc, gc, dd);
expr = CDR(expr);
}
return bbox;
}

它稍后在文件中发送:

static BBOX RenderFormula(SEXP expr, int draw, mathContext *mc,
pGEcontext gc, pGEDevDesc dd)
{
SEXP head = CAR(expr);

....
else if (ConcatenateAtom(head))
return RenderConcatenate(expr, draw, mc, gc, dd);
....

(话虽这么说,我对 C 一无所知,所以我可能是错的)

关于r - 粘贴是绘图数学表达式中的特殊参数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19563042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com