[R] What is the problem now?

Levent TERLEMEZ lterlemez at anadolu.edu.tr
Mon Jan 5 09:23:08 CET 2015


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,offset=-.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]]



More information about the R-help mailing list