2015-01-21 49 views
0

我有这段代码,它假设写一个情节包含许多小的子情节到一个文件。R写入文件剧情由子情节组成

par(mar=c(1,1,1,1)) 
    par(mfrow=c(3,3)) 

    filepath <- paste(getwd(),'/','BP_',product_name,'.jpg',sep="") 
    jpeg(filepath) 

    boxplot(normalized.price_shipping~rank, data=data.selected, main=toupper("Normalized Price By Rank Levels"), font.main=3, cex.main=1.2, xlab="Rank Levels", ylab="Price+Shpping", font.lab=3, col="darkgreen") 
    #dev.off() 

    #filepath <- paste(getwd(),'/','BP_normalized.seller_feedback_score_',product_name,'.jpg',sep="") 
    #jpeg(filepath) 
    boxplot(normalized.seller_feedback_score~rank, data=data.selected, main=toupper("normalized.seller_feedback_score By Rank Levels"), font.main=3, cex.main=1.2, xlab="Rank Levels", ylab="normalized.seller_feedback_score", font.lab=3, col="darkgreen") 
    #dev.off() 

    #filepath <- paste(getwd(),'/','BP_normalized.seller_positive_feedback_percent~rank_',product_name,'.jpg',sep="") 
    #jpeg(filepath) 
    boxplot(normalized.seller_positive_feedback_percent~rank, data=data.selected, main=toupper("normalized.seller_positive_feedback_percent By Rank Levels"), font.main=3, cex.main=1.2, xlab="Rank Levels", ylab="normalized.seller_positive_feedback_percent", font.lab=3, col="darkgreen") 
    #dev.off() 

    #filepath <- paste(getwd(),'/','BP_keywords_title_assoc~rank_',product_name,'.jpg',sep="") 
    #jpeg(filepath) 
    boxplot(keywords_title_assoc~rank, data=data.selected, main=toupper("keywords_title_assoc By Rank Levels"), font.main=3, cex.main=1.2, xlab="Rank Levels", ylab="keywords_title_assoc", font.lab=3, col="darkgreen") 
    #dev.off() 

    #filepath <- paste(getwd(),'/','BP_log10_seller_feedback_score~rank_',product_name,'.jpg',sep="") 
    #jpeg(filepath) 
    boxplot(log10(seller_feedback_score)~rank, data=data.selected, main=toupper("seller_log10_feedback_score By Rank Levels"), font.main=3, cex.main=1.2, xlab="Rank Levels", ylab="seller_feedback_score", font.lab=3, col="darkgreen") 


    dev.off() 

但是,在写入文件系统的文件中,我只能看到我需要看到的5个箱形图中的最后一个图。 任何想法为什么?

+0

此答案可能有所帮助:http://stackoverflow.com/q/13175556/1414455 – tchakravarty 2015-01-21 06:16:56

+0

找不到我的答案。我认为我的问题是不同的 - 我可以成功地看到RStudio中的所有子图,但是当写入图时,只有最后一个图显示在文件中 – user3628777 2015-01-21 06:26:42

回答

1

我想,这是因为你应该先创建jpeg文件,然后用par函数。

filepath <- paste(getwd(),'/','BP_',product_name,'.jpg',sep="") 
    jpeg(filepath) 

par(mar=c(1,1,1,1)) 
par(mfrow=c(3,3)) 
etc.