# [R] What is the problem now?

David Winsemius dwinsemius at comcast.net
Mon Jan 5 18:28:05 CET 2015

```On Jan 5, 2015, at 2:46 AM, PIKAL Petr wrote:

> Hi
> cc to list, others can have further comments
>
> substitute is superfluous
>
> see results of
>
> substitute(paste(z,sigma)
> paste(z,sigma)
> substitute(paste(z,"sigma")
> paste(z,"sigma")

Perhaps this would be more instructive (after adding back the missing parentheses):

sigma=2; for( z in -:1 ){
print( substitute(paste(z,sigma)) )
print( paste(z,sigma) )
print( substitute(paste(z,"sigma")) )
print( paste(z,"sigma") ) ; cat("\n")}

I don't know if `substitute` is so much superfluous as incompletely called. I would have thought the code might be:

substitute( paste(z, sigma), list=(z=z) ) # puts value of z into the expression

Or perhaps:

substitute( z == sigma, list=(z=z) )

Or:

bquote( .(z) == sigma)

Assuming the goal were to label a plot with the value of z in a plot at a particular location. The relevant help pages are:

?expression
?substitute
?bquote
?plotmath
?text

Best;
David.

>
> Cheers
> Petr
>
>> -----Original Message-----
>> From: Levent TERLEMEZ [mailto:lterlemez at anadolu.edu.tr]
>> Sent: Monday, January 05, 2015 10:47 AM
>> To: PIKAL Petr
>> Subject: YNT: What is the problem now?
>>
>> Hi Petr,
>>
>> Thanks, i will look at it. Can I learn the cause of problem if it is
>> not detailed?
>>
>> Levent.
>>
>> ________________________________________
>> Kimden: PIKAL Petr [petr.pikal at precheza.cz]
>> Gönderildi: 05 Ocak 2015 Pazartesi 11:25
>> Kime: Levent TERLEMEZ; r-help ‎[r-help at r-project.org]‎
>> Konu: RE: What is the problem now?
>>
>> Hi
>>
>> I am not sure what do you want to achieve.
>>
>> I would change your text function
>>
>> {text(min(gecici\$Tarih)+0.1,y,paste(z,"sigma"),cex=.85,pos=3)}
>>
>> and instead of copy paste you can open and close appropriate device
>> (pdf, jpg or emf - from devEMF package)
>>
>> Cheers
>> Petr
>>
>>
>>> -----Original Message-----
>>> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of
>> Levent
>>> TERLEMEZ
>>> Sent: Monday, January 05, 2015 9:23 AM
>>> To: r-help ‎[r-help at r-project.org]‎
>>> Subject: [R] What is the problem now?
>>>
>>> Hi Dear Users,
>>>
>>> I abonden ggplot2 adventure for the moment because of urgent results
>>> (i will of course will do this with ggplot2 because I would like to
>>> use
>>> ggplot2 much more than standart plots). But this time I came across
>>> with a different problem.
>>> Problem is different graphical outputs from screen and copy-paste. -
>> 3s
>>> to 3s texts at the desired points on the screen but only 3s text at
>>> the desired points on the copy-past to a word or another document.
>>>
>>>
>>> dput for d.oran;
>>>
>>> structure(list(Tarih = structure(c(12784, 12785, 12786, 12787,
>> 12788),
>>> class = "Date"), EUROUSD = c(1.37820047639547, 1.37321712373714,
>>> 1.36448946153273, 1.35276621058894, 1.33879335902757), USDJPY =
>>> c(1.03465373983692, 1.02726827581633, 1.02488359667201,
>>> 1.02672163689113, 1.03386973180077 ), EUROJPY = c(1.42596027714759,
>>> 1.41066238702292, 1.39844286695672, 1.38891433806688,
>>> 1.38413793103448)), .Names = c("Tarih", "EUROUSD", "USDJPY",
>>> "EUROJPY"), row.names = c(NA, 5L), class = "data.frame")
>>>
>>>
>>> dput for d.oran.ist;
>>> structure(list(x_bar = c(1.34056134982583, 0.990969887720573,
>>> 1.32651605042546, NA, NA), std_sap = c(0.0873935814603307,
>>> 0.137574609058213, 0.189820046956369, NA, NA)), .Names = c("x_bar",
>>> "std_sap"), row.names = c("EUROUSD", "USDJPY", "EUROJPY", "NA",
>>> "NA.1"), class = "data.frame")
>>>
>>>
>>> Both of these data frames are in function frames. And this my user
>>> function that produces these plots (it produces 3 plots for 3
>> exchange
>>> rates) and both 3 plots do the same thing.
>>>
>>>
>>> function(veri)
>>>    {
>>>    require(reshape2)
>>>    d.oran<-
>>>
>> data.frame(veri[,1],veri[,2]/veri[,4],veri[,4]/veri[,3],veri[,2]/veri[
>>> ,
>>> 3])
>>>    colnames(d.oran)<-c("Tarih","EUROUSD","USDJPY","EUROJPY")
>>>    dput(d.oran[1:5,])
>>>    x_bar<-colMeans(d.oran[,2:4])
>>>    std_sap<-apply(d.oran[,2:4],2,sd)
>>>    d.oran.ist<-data.frame(x_bar,std_sap)
>>>    colnames(d.oran.ist)<-c("x_bar","std_sap")
>>>    dput(d.oran.ist[1:5,])
>>>    d.oran<-melt(d.oran,id="Tarih")
>>>    d.oran\$variable<-factor(d.oran\$variable)
>>>        #print(x_bar)
>>>        #print(std_sap)
>>>    print(d.oran.ist)
>>>    print(d.oran[1:5,])
>>>    renkler<-c("red","blue","green","orange")
>>>    for(i in 1:3)
>>>        {
>>>        dev.new() # Here, I tried windows() too but nothing changed
>>>        gecici<-subset(d.oran,variable==levels(d.oran\$variable)[i])
>>>
>>>
>> plot(gecici\$Tarih,gecici\$value,main=levels(d.oran\$variable)[i],type="l"
>>> ,ylim=c(d.oran.ist[i,1]-3*d.oran.ist[i,2]-
>>> .05,d.oran.ist[i,1]+3*d.oran.ist[i,2]+.05))
>>>        #segments(min(gecici\$Tarih),d.oran.ist[i,1]+seq(-
>>> 3,3,1)*d.oran.ist[i,2],max(gecici\$Tarih),d.oran.ist[i,1]+seq(-
>>> 3,3,1)*d.oran.ist[i,2])
>>>        abline(h=d.oran.ist[i,1]+seq(-
>>> 3,3,1)*d.oran.ist[i,2],col=renkler[4-abs(seq(-3,3,1))],lty="dashed")
>>>        for(z in -3:3)
>>>            {
>>>            y<-d.oran.ist[i,1]+z*d.oran.ist[i,2]
>>>            if(z!=0)
>>>
>>>
>> {text(min(gecici\$Tarih),y,substitute(paste(z,sigma)),cex=.85,pos=3,off
>>> s
>>> et=-.0001)}
>>>            #else
>>>
>> {text(min(gecici\$Tarih),y,substitute(paste(mu)),cex=.85,pos=2,offset=1
>>> )
>>> }
>>>            }
>>>        #plot()
>>>        }
>>>    }
>>>
>>>
>>> I really appreciate your valuable time make for me, and nice advices.
>>> Thanks to everybody for sharing experiences and knowledge,
>>>
>>> Levent TERLEMEZ.
>>>
>>>
>>>
>>>      [[alternative HTML version deleted]]
>>>
>>>
>>
>>

David Winsemius
Alameda, CA, USA

```