Dear R users I am trying to exporting plots from R to an external folder, or to the working directory, but the resolution of plots (pdf file) largely reduced. Any way I can get same quality as my original plots?? e.g. I tested the plotting part using one example and obtained pretty good (/readable) quality for each plot in the (4*4) multiple graph. But when I did the loop and tried to export those plots out using 'dev.copy', the quality was not same. I do need this loop function as there are 400 datasets so I can not handle them manually.
Also I am using 'xtable' to write Latex code for my summary tables of the data (again there are 400 datasets). I saved those Latex code in a list and use 'sink()' to save them outside the loop function, which works ok. But as my table is wide, so I found that the Latex code produced by xtable can not fit my purpose well, e.g. I have set size to 'tiny' but the table still too wide. Is there an alternative package more handy to do the job? Also are there a good way to write some hundred tables from R to Latex for producing pdf documents in an easier fashion?? i.e. Just realised that Latex does not like compiling large amount tables/figures in one go! Any advices/ideas are greatly appreciated! Best wishes HJ Below is my code... ===================== SumTab<-function(Data=SortedDataInList,StartDate="30/1/12",EndDate="31/05/12",StartTime="22:50:00",EndTime="23:00:00"){ Start= chron(StartDate,StartTime , format=c(dates="d/m/y", times="h:m:s")) End= chron(EndDate,EndTime , format=c(dates="d/m/y", times="h:m:s")) deltat <- times("00:10:00") TT <- seq(Start,End, by = times("00:10:00")) TT1 = substr(TT, 2, 18) Data1=Data for (i in 1:length(Data1)){ SumTab1[[i]]= matrix(NA, nrow=5, ncol=ncol(SortedDataInList[[i]])-4) SortedDataInList1[[i]]= matrix(NA, nrow=length(TT1), ncol=ncol(Data1[[i]])) SortedDataInList1[[i]]=Data1[[i]][match(as.character(TT1),as.character(Data1[[i]][,1])),] SumTab1[[i]][1,]<-apply(SortedDataInList1[[i]][,4:16],2,min) SumTab1[[i]][2,]<-apply(SortedDataInList1[[i]][,4:16],2,mean) SumTab1[[i]][3,]<-apply(SortedDataInList1[[i]][,4:16],2,median) SumTab1[[i]][4,]<-apply(SortedDataInList1[[i]][,4:16],2,sd) SumTab1[[i]][5,]<-apply(SortedDataInList1[[i]][,4:16],2,max) colnames(SumTab1[[i]])=c("vOL1","VOL2","VOL3","CUR1","CUR2","CUR3","THD1","THD2","THD3","RPD","RPR","RAPD","RAPR") rownames(SumTab1[[i]])=c("Min","Mean","Standard Deviation","Median","Max") SumLax[[i]]<-xtable(SumTab1[[i]],label=as.character(StationsInDir[i]),caption=as.character(StationsInDir[i])) par(mfrow=c(4,4),oma=c(4,0,2,0)) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,4],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Voltage 1 (v)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,5],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Voltage 2 (v)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,6],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Voltage 3 (v)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,7],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Current 1 (A)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,8],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Current 2 (A)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,9],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Current 3 (A)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,10],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Total harmonic distortion 1 (%)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,11],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Total harmonic distortion 2 (%)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,12],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Total harmonic distortion 3 (%)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,13],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Real power delivered (mw)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,14],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Real power received (mw)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,15],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Reactive power delivered (MVAr)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) plot(1:length(SortedDataInList1[[i]][,1]),SortedDataInList1[[i]][,16],xlim=c(1,length(SortedDataInList1[[i]][,1])),ylab="Reactive power received (MVAr)",xlab="Date/Time ind.(10 min. int.)",type="p",cex=.001) title(main=StationsInDir[i],outer=TRUE,cex.main=2.0) mtext(side=1,Start, outer = TRUE, line=0,cex = 0.6) mtext(side=1,End, outer = TRUE, line=2,cex = 0.6) #pdf(paste(as.character(StationsInDir[i]),".pdf")) dev.copy(pdf,file=paste(as.character(StationsInDir[i]),".pdf")) dev.off() } } [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.