[R] barplot in a loop not printing out to directory

Jim Lemon jim at bitwrit.com.au
Sat May 16 15:12:51 CEST 2009


Dimitri Liakhovitski wrote:
> Hello!
> I am experiencing a problem with section 3 of the code below. I want
> to generate barplots (based on data generated in Sections 1 and 2) in
> a loop - for each variable in "data" - and save them as .emf files in
> my current directory. But it's not working - it's printing values to
> be plotted to the screen but does not print the plots themselves
> anywhere (and not in the directory).
> Thank you very much for your help!
> Dimitri
> ...
I would insert a line just after filename=...
cat(filename,"\n")
and see what the filenames are.

Jim
> ### Section 3. I want to generate a barplot based on each and every
> table I produced above and put it in my current directory. But it's
> not working.
>
> for(i in 1:length(tables)) {
> 	chart.name<-names(data)[i]
> 	filename=paste(i,chart.name,"emf",sep=".")
> 	win.metafile(file=filename)
> 	chart<-barplot(tables[[i]][[2]],xlab = "Values", ylab =
> "Percentages",ylim=c(0,100))
> 	print(chart)
> 	dev.off()
> }
>
> Thank you very much!
>




More information about the R-help mailing list