Use a variable within a plotmath expression

后端 未结 3 993
傲寒
傲寒 2020-11-30 06:45

I\'m trying to place the results of a regression (i.e., R2) in a graph, but can\'t seem to figure out how to call a variable from within an expression (it pastes the variabl

3条回答
  •  情歌与酒
    2020-11-30 07:20

    To combine substitute() and paste(), I use the following code;

    waic <-1;
    chisquare <-2;
    plot(x=1:2,y=1:2, 
         main =  substitute(paste(
        "chi^2 goodness of fit ", 
           chi^2*(D/theta) , "=",  chisquare ,
           ".  WAIC =",waic),
    
    
    list(chisquare=chisquare,waic=waic)  
    )
    )
    

    The result is the following;

提交回复
热议问题