diff --git a/src/R/PCA.R b/src/R/PCA.R
index 4d79661ffce6746c84b6327812c56ddda595fa94..689026eb66d23be9b530141c64d0f822428ab9e2 100755
--- a/src/R/PCA.R
+++ b/src/R/PCA.R
@@ -174,6 +174,10 @@ for (i in seq_len(length(par.l$files_rawCounts))) {
     # PCA plot #
     ############
     
+    if (!dir.exists(unique(dirname(par.l$files_output_PCA_plot)))) {
+        dir.create(unique(dirname(par.l$files_output_PCA_plot)))
+    }
+    
     pdf(par.l$files_output_PCA_plot[i], height = pdf_width, width = pdf_width)
     
     pca.data[[listname]] = counts.dd
@@ -192,6 +196,10 @@ for (i in seq_len(length(par.l$files_rawCounts))) {
     
     cor.data[[listname]] = countsCur.m.cor
     
+    if (!dir.exists(unique(dirname(par.l$files_output_cor_plot[i])))) {
+        dir.create(unique(dirname(par.l$files_output_cor_plot[i])))
+    }
+    
     pdf(par.l$files_output_cor_plot[i], height = pdf_height, width = pdf_width)
     
     titleCur = paste0("\nSample correlation for file ", basename(dirname(listname)), "/", basename(listname))