X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=PrintRScript.py;h=636fe9ee8515d8a6b4d6b32f6f04e2d053f3b9ac;hp=b29f813314ab8247f6a758e9ca4c72a08a973ab8;hb=2ffa9388c45dce689bb45c1cf6c7ad81d2636409;hpb=42a67a41b64a6e0cc3fd2a63a0749e9aa4b9374c diff --git a/PrintRScript.py b/PrintRScript.py index b29f813..636fe9e 100644 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -33,7 +33,7 @@ class PrintRScript : def sources(self, lsources) : for source in lsources : - self.add('source("%s")' % source) + self.add('source("%s", encoding = \'utf8\')' % source) def packages(self, lpks) : for pk in lpks : @@ -253,7 +253,6 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv def RPamTxt(corpus, RscriptPath): DicoPath = corpus.pathout param = corpus.parametres - print param txt = """ source("%s") """ % (RscriptPath['pamtxt']) @@ -394,7 +393,9 @@ write.csv2(gbcluster,file="%s") PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debsup, fin=(debet-1), xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (DictChdTxtOut['AFC2DSL_OUT']) txt += """ + if ((fin - debet) > 2) { PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) + } """ % (DictChdTxtOut['AFC2DEL_OUT']) txt += """ PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col=TRUE, what='coord', xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) @@ -544,6 +545,7 @@ def barplot(table, rownames, colnames, rgraph, tmpgraph, intxt = False) : # height = 400 rownames = 'c("' + '","'.join(rownames) + '")' colnames = 'c("' + '","'.join(colnames) + '")' + if not intxt : #FIXME txt = """ @@ -1091,7 +1093,14 @@ class WordCloudRScript(PrintRScript) : self.packages(['wordcloud']) bg_col = Rcolor(self.parametres['col_bg']) txt_col = Rcolor(self.parametres['col_text']) + if self.parametres['svg'] : + svg = 'TRUE' + else : + svg = 'FALSE' txt = """ + svg <- %s + """ % svg + txt += """ act <- read.csv2("%s", header = FALSE, row.names=1, sep='\t') selected.col <- read.table("%s") toprint <- as.matrix(act[selected.col[,1] + 1,]) @@ -1101,10 +1110,24 @@ class WordCloudRScript(PrintRScript) : toprint <- as.matrix(toprint[order(toprint[,1], decreasing=TRUE),]) toprint <- as.matrix(toprint[1:maxword,]) } - open_file_graph("%s", width = %i, height = %i) + open_file_graph("%s", width = %i, height = %i , svg = svg) par(bg=rgb%s) wordcloud(row.names(toprint), toprint[,1], scale=c(%f,%f), random.order=FALSE, colors=rgb%s) dev.off() """ % (ffr(self.analyse.pathout['actives_eff.csv']), ffr(self.analyse.pathout['selected.csv']), self.parametres['maxword'], ffr(self.parametres['graphout']), self.parametres['width'], self.parametres['height'], bg_col, self.parametres['maxcex'], self.parametres['mincex'], txt_col) self.add(txt) self.write() + +class ProtoScript(PrintRScript) : + def make_script(self) : + self.sources([self.analyse.parent.RscriptsPath['Rgraph'], self.analyse.parent.RscriptsPath['prototypical.R']]) + self.packages(['wordcloud']) + txt = """ + mat <- read.csv2("%s", header = FALSE, row.names=1, sep='\t', quote='"', dec='.') + open_file_graph("%s",height=600, width=600) + prototypical(mat, mfreq = %s, mrank = %s, cloud = FALSE, cexrange=c(1,2.4), cexalpha= c(0.4, 1)) + dev.off() + """ % (self.analyse.pathout['table.csv'], self.analyse.pathout['proto.png'], self.parametres['limfreq'], self.parametres['limrang']) + self.add(txt) + self.write() +