# open_file_graph("%s", widt = 600, height=400)
# plot(tree.tot1$tree.cl)
# dev.off()
- """%DicoPath['arbre1']
+ """ % DicoPath['arbre1']
if classif_mode == 0:
txt += """
#x a table with freq and rank, rownames are words
-prototypical <- function(x, mfreq = NULL, mrank = NULL, cexrange=c(0.8, 3), cexalpha = c(0.5, 1), labfreq = TRUE, labrank = TRUE, cloud = TRUE) {
+prototypical <- function(x, mfreq = NULL, mrank = NULL, cexrange=c(0.8, 3), cexalpha = c(0.5, 1), labfreq = TRUE, labrank = TRUE, cloud = TRUE, type = 'classical') {
library(wordcloud)
if (is.null(mfreq)) {
mfreq <- sum(x[,1]) / nrow(x)
labcex <- norm.vec(x[,1], cexrange[1], cexrange[2])
labalpha <- norm.vec(x[,2], cexalpha[2], cexalpha[1])
labalpha <- rgb(0.1,0.2,0.1, labalpha)
- par(oma=c(1,3,3,1))
- layout(matrix(c(1,4,2,3), nrow=2))
+ labcol <- rep('black', nrow(x))
+ labcol[FP] <- 'red'
+ labcol[SP] <- 'green'
+ labcol[ZN] <- 'blue'
ti <- c("Zone du noyau", "Première périphérie", "Seconde périphérie", "Elements contrastés")
- for (i in 1:length(toplot)) {
- rtoplot <- toplot[[i]]
- if (length(rtoplot)) {
- par(mar=c(0,0,2,0))
- if (cloud) {
- labels <- paste(rownames(x)[rtoplot], x[rtoplot,1], x[rtoplot,2], sep='-')
- wordcloud(labels, x[rtoplot,1], scale = c(max(labcex[rtoplot]), min(labcex[rtoplot])), color = labalpha[rtoplot], random.order=FALSE, rot.per = 0)
- box()
- } else {
- yval <- 1.1
- plot(0,0,pch='', axes = FALSE)
- k<- 0
- for (val in rtoplot) {
- yval <- yval-(strheight(rownames(x)[val],cex=labcex[val])+0.02)
- text(-0.9, yval, paste(rownames(x)[val], x[val,1], x[val,2], sep = '-'), cex = labcex[val], col = labalpha[val], adj=0)
- }
- box()
- }
- title(ti[i])
- }
- }
- mtext(paste('<', mfreq, ' Fréquences ', '>=', mfreq, sep = ' '), side=2, line=1, cex=1, col="red", outer=TRUE)
- mtext(paste('<=', mrank, ' Rangs ', '>', mrank, sep = ' '), side=3, line=1, cex=1, col="red", outer=TRUE)
+ if (type == 'classical') {
+ par(oma=c(1,3,3,1))
+ layout(matrix(c(1,4,2,3), nrow=2))
+ for (i in 1:length(toplot)) {
+ rtoplot <- toplot[[i]]
+ if (length(rtoplot)) {
+ par(mar=c(0,0,2,0))
+ if (cloud) {
+ labels <- paste(rownames(x)[rtoplot], x[rtoplot,1], x[rtoplot,2], sep='-')
+ wordcloud(labels, x[rtoplot,1], scale = c(max(labcex[rtoplot]), min(labcex[rtoplot])), color = labalpha[rtoplot], random.order=FALSE, rot.per = 0)
+ box()
+ } else {
+ yval <- 1.1
+ plot(0,0,pch='', axes = FALSE)
+ k<- 0
+ for (val in rtoplot) {
+ yval <- yval-(strheight(rownames(x)[val],cex=labcex[val])+0.02)
+ text(-0.9, yval, paste(rownames(x)[val], x[val,1], x[val,2], sep = '-'), cex = labcex[val], col = labalpha[val], adj=0)
+ }
+ box()
+ }
+ title(ti[i])
+ }
+ }
+ mtext(paste('<', mfreq, ' Fréquences ', '>=', mfreq, sep = ' '), side=2, line=1, cex=1, col="red", outer=TRUE)
+ mtext(paste('<=', mrank, ' Rangs ', '>', mrank, sep = ' '), side=3, line=1, cex=1, col="red", outer=TRUE)
+ } else if (type == 'plan') {
+ par(oma=c(3,3,1,1))
+ textplot(x[,1], x[,2], rownames(x), cex=labcex, xlim=c(min(x[,1])-nrow(x)/3, max(x[,1])+5), ylim = c(min(x[,2])-0.2, max(x[,2])+0.5), col=labcol, xlab="", ylab="")
+ abline(v=mfreq)
+ abline(h=mrank)
+ legend('topright', ti, fill=c('blue', 'red', 'green', 'black'))
+ mtext(paste('<', mfreq, ' Fréquences ', '>=', mfreq, sep = ' '), side=1, line=1, cex=1, col="red", outer=TRUE)
+ mtext(paste('<=', mrank, ' Rangs ', '>', mrank, sep = ' '), side=2, line=1, cex=1, col="red", outer=TRUE)
+ }
}
intervalle.freq <- function(x, SX=NULL) {
def __del__( self ):
pass
-class FreqDialog(wx.Dialog):
- def __init__(self, parent, ID, listcol, title, size) :
- wx.Dialog.__init__(self, parent, ID, title, size=size, pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK )
- pre = wx.PreDialog()
- pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
- pre.Create(parent, ID, title, wx.DefaultPosition, size, wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK)
- self.PostCreate(pre)
- self.parent = parent
- sizer = wx.BoxSizer(wx.VERTICAL)
- #self.content = parent.content
+# class FreqDialog(wx.Dialog):
+# def __init__(self, parent, ID, listcol, title, size) :
+# wx.Dialog.__init__(self, parent, ID, title, size=size, pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK )
+# pre = wx.PreDialog()
+# pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
+# pre.Create(parent, ID, title, wx.DefaultPosition, size, wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK)
+# self.PostCreate(pre)
+# self.parent = parent
+# sizer = wx.BoxSizer(wx.VERTICAL)
+# #self.content = parent.content
+# self.header = listcol
+# #LABELLIST = []
+# #for i in self.header:
+# # forme = i
+# # if len(forme) > 60 :
+# # LABELLIST.append(i[0:60])
+# # else:
+# # LABELLIST.append(i)
+# self.list_box_1 = wx.ListBox(self, -1, choices=self.header, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
+# sizer.Add(self.list_box_1, 0, 5)
+#
+# btnsizer = wx.BoxSizer(wx.HORIZONTAL)
+#
+# btn = wx.Button(self, wx.ID_CANCEL)
+# btnsizer.Add(btn)
+#
+# btn = wx.Button(self, wx.ID_OK)
+# btn.SetDefault()
+# btnsizer.Add(btn)
+#
+# sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
+# self.SetSizer(sizer)
+# sizer.Fit(self)
+# self.SetTitle(_(u"Selection").decode('utf8'))
+#
+ # end wxGlade
+
+
+class FreqDialog ( wx.Dialog ):
+
+ def __init__( self, parent, listcol, title, size = wx.Size( -1,-1 ), showNA = True):
+ wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE )
+
self.header = listcol
- #LABELLIST = []
- #for i in self.header:
- # forme = i
- # if len(forme) > 60 :
- # LABELLIST.append(i[0:60])
- # else:
- # LABELLIST.append(i)
- self.list_box_1 = wx.ListBox(self, -1, choices=self.header, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
- sizer.Add(self.list_box_1, 0, 5)
-
- btnsizer = wx.BoxSizer(wx.HORIZONTAL)
- btn = wx.Button(self, wx.ID_CANCEL)
- btnsizer.Add(btn)
+ self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
- btn = wx.Button(self, wx.ID_OK)
- btn.SetDefault()
- btnsizer.Add(btn)
+ bSizer1 = wx.BoxSizer( wx.VERTICAL )
- sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
- self.SetSizer(sizer)
- sizer.Fit(self)
- self.SetTitle(_(u"Selection").decode('utf8'))
-
- # end wxGlade
+ m_listBox1Choices = self.header
+ self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL|wx.LB_MULTIPLE )
+ self.m_listBox1.SetMinSize( wx.Size( 500,-1 ) )
+ bSizer1.Add( self.m_listBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+
+ if showNA :
+ fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
+ fgSizer1.SetFlexibleDirection( wx.BOTH )
+ fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
+
+ self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Include empty cells (NA)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
+ self.m_staticText1.Wrap( -1 )
+ fgSizer1.Add( self.m_staticText1, 0, wx.ALL, 5 )
+
+ self.includeNA = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
+ fgSizer1.Add( self.includeNA, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+
+ bSizer1.Add( fgSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
+
+ m_sdbSizer1 = wx.StdDialogButtonSizer()
+ self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
+ m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
+ self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
+ m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
+ m_sdbSizer1.Realize();
+
+ bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
+
+
+ self.SetSizer( bSizer1 )
+ self.Layout()
+ bSizer1.Fit( self )
+
+ self.Centre( wx.BOTH )
+
+ def __del__( self ):
+ pass
+
+
class ProtoDial ( wx.Dialog ):
if dlg is None :
return
else :
- dial = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Fréquences", size=(350, 200))
+ dial = FreqDialog(self.parent, self.tableau.get_colnames(), u"Fréquences")
dial.CenterOnParent()
val = dial.ShowModal()
if val == wx.ID_OK :
- self.parametres['colsel'] = dial.list_box_1.GetSelections()
+ self.parametres['colsel'] = dial.m_listBox1.GetSelections()
self.parametres['header'] = dial.header
+ self.parametres['NA'] = dial.includeNA.GetValue()
else :
self.parametres = None
dial.Destroy()
compteur <- 1
""" % (sel, listfiles, titles)
+ if self.parametres['NA'] :
+ txt += """
+ countNA <- TRUE
+ """
+ else :
+ txt += """
+ countNA <- FALSE
+ """
+
txt += """
for (i in select) {
- freq <- table(dm[,i])
+ if (countNA) {
+ freq <- table(dm[,i], useNA = 'ifany')
+ } else {
+ freq <- table(dm[,i])
+ }
sumfreq <- sum(freq)
pour <- prop.table(as.matrix(freq), 2) * 100
sumpour <- sum(pour)
+ pour <- round(pour, 2)
ntable <- cbind(as.matrix(freq), pour)
graphout <- listfiles[compteur]
if (Sys.info()["sysname"]=='Darwin') {
self.tableau = parent.tableau
self.tableau.parametres['mineff'] = 0
if not self.fromprof :
- dialcol = FreqDialog(self.parent, -1, self.tableau.get_colnames(), _(u"Select columns").decode('utf8'), size=(600, 250))
+ dialcol = FreqDialog(self.parent, self.tableau.get_colnames(), _(u"Select columns").decode('utf8'), size=(600, 250), showNA = False)
dialcol.CenterOnParent()
res = dialcol.ShowModal()
else :
if dlg is None :
return
else :
- dial = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Column", size=(350, 200))
+ dial = FreqDialog(self.parent, self.tableau.get_colnames(), u"Column", size=(350, 200), showNA = False)
dial.CenterOnParent()
val = dial.ShowModal()
if val == wx.ID_OK :