[R] try to generate graph for each element of my list

n.vialma at libero.it n.vialma at libero.it
Fri Jun 24 21:29:55 CEST 2011


Dear all,
I have the following problem. I have a List of time series dataframe.I'm 
trying to produce specific graph for each element of my list. The code is:
This is my list:
Lista_import<-lapply(Lista_import, function(x){
x2<-subset(x, select=c("ANNO","DICHIARANTE","PARTNER", "quota"))
x2<-cast(x2, ANNO+DICHIARANTE~PARTNER)
x2<- as.xts(as.matrix(as.timeSeries(x2)))
return(x2)})


each list have the following  shape:
$AUS
$DEU
and data inside...I'm not showing you the content cause I think is not 
relevant


For the GRaph the code is

c<-lapply(Lista_import,function(x){
for(i in names(Lista_import)){      

legenda <- read.csv
("/home/fturrini/Tessile/01_Dati_complementari/Legenda_paese.csv",header=TRUE)
leg <- data.frame(ISO3=colnames(x),inutile=1)
legenda <- merge(legenda,leg, by="ISO3", all.y=TRUE)

png(paste("/home/Tessile/Output/Gra/MaxM/QuoteEXperPaese_",i,".png"), 
width=1661,height=828)


graph <-{par(bg="grey97", font=3,font.axis=3,bty="l",las=1, mar=c(8,6,4,2),
xpd=FALSE)
yrange<-c(min(x,na.rm=TRUE), 1.05*max(x,na.rm=TRUE))
colori <- c("Blue","Aquamarine1", "Firebrick3", "Chocolate4", "BlueViolet", 
"Yellow3")

chart.TimeSeries(x, type="l",lwd=5, ylab="", xlab="", main="", date.format="%
Y", ylim=yrange, col=colori, 
cex.axis=1.6, major.ticks="years", minor.ticks=FALSE, grid.color="gray50", 
grid.lty="dotted")
legend("topleft",as.character(legenda$PAESE),bty="n",cex=1.7,lwd=5, ncol=2, 
col=colori, horiz=F)
mtext("Fonte: Unctad, Pctas", side=1,line=5,adj=1,cex=1.8,col="grey20")
mtext(p, side=1,line=5,adj=0,cex=1.5,col="grey10")}}
dev.off()
rm(grafico)
})

The results is that I get the same graph for each element of my list.....
Someone knows how to get one graph for each element of my list pasting the 
names' list element  in the .png file??
Thanks for your attention!



More information about the R-help mailing list