i'm saving several plots in loop png files. works great, i've closed r. long i'm in rstudio, files have size of 0 kb , cannot opened since in use program. why that? did forget code something?
here's loop:
plotbasketandsavetodirectory<-function(basketname, savetodirectory){ basketvariables <- readvariablesfrombasket(basketname) for(i in 1:nrow(basketvariables)){ variablecsv<-read.table(getvariablecsvpath(basketvariables[i,1]),header=true,stringsasfactors=false,sep=",") variablecsv$date<-as.date(as.character(variablecsv$date), format="%y/%m/%d") variablexts<-xts(variablecsv$close, order.by=variablecsv$date) png(file=paste(savetodirectory,basketvariables[i,1],".png",sep="")) plot(variablexts, main=basketvariables[i,1]) dev.off } }
in order formally end question, adding comment answer:
dev.off()
function , must followed round brackets.
Comments
Post a Comment