mydata<-read.csv ("comp-soc.csv",header=T) attach(mydata) png(filename="comp-soc1.png",width=600,height=600,bg="white") plot (SocSpending,CompetInd, xlab="Dépenses sociales (% PIB)", ylab="Indice de compétitivité (GCI)", pch=16) f<-lm(CompetInd ~ SocSpending) abline(coef(f)) # # R2 # R2=cor (CompetInd, SocSpending) ^ 2 text (20,4, as.expression (substitute(italic(R)^2==r,list(r=round(R2,3))))) dev.off() #----------------------------- png(filename="comp-soc2.png",width=600,height=600,bg="white") plot (SocSpendNoUnemp,CompetInd, xlab="Dépenses sociales hors chômage (% PIB)", ylab="Indice de compétitivité (GCI)", pch=16) f<-lm(CompetInd ~ SocSpendNoUnemp) abline(coef(f)) # # R2 # R2=cor (CompetInd, SocSpendNoUnemp) ^ 2 text (20,4, as.expression (substitute(italic(R)^2==r,list(r=round(R2,3))))) dev.off()