[Rqda-commits] r26 - pkg pkg/R pkg/man www

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 2 18:50:22 CET 2008


Author: wincent
Date: 2008-12-02 18:50:22 +0100 (Tue, 02 Dec 2008)
New Revision: 26

Added:
   pkg/R/CaseFun.R
   pkg/man/write.FileList.RD
Modified:
   pkg/ChangeLog
   pkg/DESCRIPTION
   pkg/R/CaseButton.R
   pkg/R/CodesFun.R
   pkg/R/GUIHandler.R
   pkg/R/root_gui.R
   pkg/TODO
   www/ChangeLog.txt
   www/index.html
Log:


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/ChangeLog	2008-12-02 17:50:22 UTC (rev 26)
@@ -1,3 +1,8 @@
+2008-12-03
+	* Attached file to case by pop-up menu in Files Tab.
+	* Now can open associated files of a case from Cases Tab.
+	* new function of write.FileList() to import a batch of files.
+	
 2008-12-01
 	* enhance the rename buttons.
 	* bugfix of add buttons: continue only when click confirm in the ginput widget.
@@ -2,2 +7,3 @@
 	* New function write.FileList() to import files by batch.
+	* Enchance the retrieval2 function so coding on the file (openned by clicking back button) is possible.
 	

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/DESCRIPTION	2008-12-02 17:50:22 UTC (rev 26)
@@ -1,10 +1,10 @@
 Package: RQDA
 Type: Package
-Title: Qualitative data analysis
-Version: 0.1.5-25
+Title: Qualitative Data Analysis
+Version: 0.1.5-26
 Date: 2008-11-01
-Author: Huang Ronggui
-Maintainer: Huang <ronggui.huang at gmail.com>
+Author: HUANG Ronggui
+Maintainer: HUANG Ronggui <ronggui.huang at gmail.com>
 Depends: DBI, RSQLite, RGtk2, gWidgets, gWidgetsRGtk2
 Description: Qualitative Data Analysis based on R language. Current version only supports plain text.
 License: FreeBSD

Modified: pkg/R/CaseButton.R
===================================================================
--- pkg/R/CaseButton.R	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/R/CaseButton.R	2008-12-02 17:50:22 UTC (rev 26)
@@ -1,17 +1,3 @@
-CaseNamesUpdate <- function(CaseNamesWidget=.rqda$.CasesNamesWidget,...)
-{
-  if (isIdCurrent(.rqda$qdacon)){
-  CaseName <- dbGetQuery(.rqda$qdacon, "select name, id from cases where status=1")
-  if (nrow(CaseName)!=0) {
-    Encoding(CaseName[['name']]) <- "UTF-8"
-    tryCatch(CaseNamesWidget[] <- CaseName[['name']], error=function(e){})
-  } else tryCatch(CaseNamesWidget[] <- NULL, error=function(e){}) 
-## when nrow(CaseName)==0, update it to NULL
-}
-}
-
-#################
-
 AddCaseButton <- function(label="ADD"){
   gbutton(label,handler=function(h,...) {
     if (is_projOpen(env=.rqda,conName="qdacon")) {
@@ -69,60 +55,7 @@
 }
 
 
-###############
-AddCase <- function(name,conName="qdacon",assignenv=.rqda,...) {
-  if (name != ""){
-    con <- get(conName,assignenv)
-    maxid <- dbGetQuery(con,"select max(id) from cases")[[1]]
-    nextid <- ifelse(is.na(maxid),0+1, maxid+1)
-    write <- FALSE
-    if (nextid==1){
-      write <- TRUE
-    } else {
-      dup <- dbGetQuery(con,sprintf("select name from cases where name=='%s'",name))
-      if (nrow(dup)==0) write <- TRUE
-    }
-    if (write ) {
-      dbGetQuery(con,sprintf("insert into cases (name, id, status,date,owner)
-                                            values ('%s', %i, %i,%s, %s)",
-                             name,nextid, 1, shQuote(date()),shQuote(.rqda$owner)))
-    }
-  }
-}
 
-
-CaseMark_Button<-function(){
-  gbutton("Mark",
-          handler=function(h,...) {
-            if (is_projOpen(env=.rqda,conName="qdacon")) {
-              con <- .rqda$qdacon
-                                   tryCatch({
-                                     ans <- mark(get(h$action$widget,env=.rqda)) ## can change the color
-                                     if (ans$start != ans$end){ 
-                                       ## when selected no text, makes on sense to do anything.
-                                       SelectedCase <- svalue(.rqda$.CasesNamesWidget)
-                                       Encoding(SelectedCase) <- "UTF-8"
-                                       currentCid <-  dbGetQuery(con,sprintf("select id from cases where name=='%s'",
-                                                                             SelectedCase))[,1]
-                                       SelectedFile <- svalue(.rqda$.root_edit)
-                                       Encoding(SelectedFile) <- "UTF-8"
-                                       currentFid <-  dbGetQuery(con,sprintf("select id from source where name=='%s'",
-                                                                             SelectedFile))[,1]
-                                       DAT <- data.frame(cid=currentCid,fid=currentFid,
-                                                         selfirst=ans$start,selend=ans$end,status=1,
-                                                         owner=.rqda$owner,date=date(),memo="")
-                                       success <- dbWriteTable(.rqda$qdacon,"caselinkage",DAT,row.name=FALSE,append=TRUE)
-                                       if (!success) gmessage("Fail to write to database.")
-                                     }
-                                   },error=function(e){}
-                                            )
-            }
-          },
-          action=list(widget=".openfile_gui")
-          )
-}
-
-
 CaseMemoButton <- function(label="Memo",...){
   gbutton(label, handler=function(h,...) {
     ## code memo: such as meaning of code etc.
@@ -202,5 +135,10 @@
 }
 
 
-
-
+## pop-up menu of add to case
+AddFileToCaseMenu <- list()
+AddFileToCaseMenu$AddFileTo$handler <- function(h, ...) {
+    if (is_projOpen(env = .rqda, conName = "qdacon", message = FALSE)) {
+      AddFileToCaselinkage()
+    }
+  }

Added: pkg/R/CaseFun.R
===================================================================
--- pkg/R/CaseFun.R	                        (rev 0)
+++ pkg/R/CaseFun.R	2008-12-02 17:50:22 UTC (rev 26)
@@ -0,0 +1,133 @@
+CaseNamesUpdate <- function(CaseNamesWidget=.rqda$.CasesNamesWidget,...)
+{
+  if (isIdCurrent(.rqda$qdacon)){
+  CaseName <- dbGetQuery(.rqda$qdacon, "select name, id from cases where status=1")
+  if (nrow(CaseName)!=0) {
+    Encoding(CaseName[['name']]) <- "UTF-8"
+    tryCatch(CaseNamesWidget[] <- CaseName[['name']], error=function(e){})
+  } else tryCatch(CaseNamesWidget[] <- NULL, error=function(e){}) 
+## when nrow(CaseName)==0, update it to NULL
+}
+}
+
+#################
+###############
+AddCase <- function(name,conName="qdacon",assignenv=.rqda,...) {
+  if (name != ""){
+    con <- get(conName,assignenv)
+    maxid <- dbGetQuery(con,"select max(id) from cases")[[1]]
+    nextid <- ifelse(is.na(maxid),0+1, maxid+1)
+    write <- FALSE
+    if (nextid==1){
+      write <- TRUE
+    } else {
+      dup <- dbGetQuery(con,sprintf("select name from cases where name=='%s'",name))
+      if (nrow(dup)==0) write <- TRUE
+    }
+    if (write ) {
+      dbGetQuery(con,sprintf("insert into cases (name, id, status,date,owner)
+                                            values ('%s', %i, %i,%s, %s)",
+                             name,nextid, 1, shQuote(date()),shQuote(.rqda$owner)))
+    }
+  }
+}
+
+
+CaseMark_Button<-function(){
+  gbutton("Mark",
+          handler=function(h,...) {
+            if (is_projOpen(env=.rqda,conName="qdacon")) {
+              con <- .rqda$qdacon
+                                   tryCatch({
+                                     ans <- mark(get(h$action$widget,env=.rqda)) ## can change the color
+                                     if (ans$start != ans$end){ 
+                                       ## when selected no text, makes on sense to do anything.
+                                       SelectedCase <- svalue(.rqda$.CasesNamesWidget)
+                                       Encoding(SelectedCase) <- "UTF-8"
+                                       currentCid <-  dbGetQuery(con,sprintf("select id from cases where name=='%s'",
+                                                                             SelectedCase))[,1]
+                                       SelectedFile <- svalue(.rqda$.root_edit)
+                                       Encoding(SelectedFile) <- "UTF-8"
+                                       currentFid <-  dbGetQuery(con,sprintf("select id from source where name=='%s'",
+                                                                             SelectedFile))[,1]
+                                       DAT <- data.frame(cid=currentCid,fid=currentFid,
+                                                         selfirst=ans$start,selend=ans$end,status=1,
+                                                         owner=.rqda$owner,date=date(),memo="")
+                                       success <- dbWriteTable(.rqda$qdacon,"caselinkage",DAT,row.name=FALSE,append=TRUE)
+                                       if (!success) gmessage("Fail to write to database.")
+                                     }
+                                   },error=function(e){}
+                                            )
+            }
+          },
+          action=list(widget=".openfile_gui")
+          )
+}
+
+
+
+AddFileToCaselinkage <- function(){
+  ## filenames -> fid -> selfirst=0; selend=nchar(filesource)
+  filename <- svalue(.rqda$.fnames_rqda)
+  Encoding(filename) <- "unknown"
+  query <- dbGetQuery(.rqda$qdacon,sprintf("select id, file from source where name = '%s' and status=1",filename))
+  fid <- query$id
+  Encoding(query$file) <- "UTF-8"
+  selend <- nchar(query$file)
+  
+  ## select a case name -> caseid
+  cases <- dbGetQuery(.rqda$qdacon,"select id, name from cases where status=1")
+  if (nrow(cases)!=0){
+    Encoding(cases$name) <- "UTF-8"
+    ans <- select.list(cases$name,multiple=FALSE)
+    if (length(ans)!=0){
+    ans <- iconv(ans,to="UTF-8")
+    caseid <- cases$id[cases$name %in% ans]
+    
+    exist <- dbGetQuery(.rqda$qdacon,sprintf("select fid from caselinkage where status=1 and fid=%i and caseid=%i",fid,caseid))
+    if (nrow(exist)==0){
+    ## write only when the selected file associated with specific case is not in the caselinkage table
+    DAT <- data.frame(caseid=caseid, fid=fid, selfirst=0, selend=selend, status=1,owner=.rqda$owner,data=date(),memo='')
+    success <- dbWriteTable(.rqda$qdacon,"caselinkage",DAT,row.name=FALSE,append=TRUE)
+    ## write to caselinkage table
+    if (!success) gmessage("Fail to write to database.")
+   }
+  }
+}
+}
+
+
+UpdateFileofCaseWidget <- function(con=.rqda$qdacon,Widget=.rqda$.FileofCase){
+  Selected <- svalue(.rqda$.CasesNamesWidget)
+  if (length(Selected)!=0){
+    caseid <- dbGetQuery(.rqda$qdacon,sprintf("select id from cases where status=1 and name='%s'",Selected))[,1]
+    ## Encoding(Selected) <- "UTF-8"
+    Total_fid <- dbGetQuery(con,sprintf("select fid from caselinkage where status==1 and caseid==%i",caseid))
+    if (nrow(Total_fid)!=0){
+      items <- dbGetQuery(con,"select name,id from source where status==1")
+      if (nrow(items)!=0) {
+        items <- items[items$id %in% Total_fid$fid,"name"]
+        Encoding(items) <- "UTF-8"
+      } else items <- NULL
+    } else items <- NULL
+  } else items <- NULL
+    tryCatch(Widget[] <- items,error=function(e){})
+}
+
+HL_Case <- function(){
+            if (is_projOpen(env=.rqda,conName="qdacon")) {
+              con <- .rqda$qdacon
+              SelectedFile <- svalue(.rqda$.root_edit)
+              ## Encoding(SelectedFile) <- "UTF-8"
+              currentFid <-  dbGetQuery(con,sprintf("select id from source where name=='%s'",SelectedFile))[,1]
+              W <- .rqda$.openfile_gui
+              if (length(currentFid)!=0) {
+                mark_index <-
+                  dbGetQuery(con,sprintf("select selfirst,selend from caselinkage where fid=%i and status==1",currentFid))
+                if (nrow(mark_index)!=0){
+                  ClearMark(W ,0 , max(mark_index$selend))
+                  HL(W,index=mark_index)
+                }
+              }
+            }
+          }

Modified: pkg/R/CodesFun.R
===================================================================
--- pkg/R/CodesFun.R	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/R/CodesFun.R	2008-12-02 17:50:22 UTC (rev 26)
@@ -154,22 +154,23 @@
       ## modification begins
         ComputeCallbackFun <- function(BeginPosition,EndPosition,FileName){
           CallBackFUN <- function(button){  
-            tryCatch(dispose(.rqda$.rootBackToFile),error=function(e) {})
+            tryCatch(dispose(.rqda$.root_edit),error=function(e) {})
             root <- gwindow(title=FileName, parent=c(370,40),width=580,height=300)
-            assign(".rootBackToFile",root,env=.rqda)
-            displayFile <- gtext(container=root,font.attr=c(sizes="large"))
-            assign(".displayFile",displayFile,env=.rqda)
+            ## use the same names as the of ViewFile, so can do coding when back to the original file.
+            assign(".root_edit",root,env=.rqda)
+            displayFile <- gtext(container=.rqda$.root_edit,font.attr=c(sizes="large"))
+            assign(".openfile_gui",displayFile,env=.rqda)
             content <- dbGetQuery(.rqda$qdacon, sprintf("select file from source where name='%s'",FileName))[1,1]
             Encoding(content) <- "UTF-8" ## so it display correct in the gtext widget
-            add(.rqda$.displayFile,content,font.attr=c(sizes="large"))
-            HL(.rqda$.displayFile,data.frame(begin=BeginPosition,end=EndPosition))
-            .rqda$.displayFile at widget@widget$SetEditable(FALSE)
-            MarkHere <- .rqda$.displayFile at widget@widget$GetBuffer()$CreateMark(mark.name = "MarkHere", where=.rqda$.displayFile at widget@widget$GetBuffer()$GetIterAtOffset(BeginPosition)$iter)
+            add(.rqda$.openfile_gui,content,font.attr=c(sizes="large"))
+            HL(.rqda$.openfile_gui,data.frame(begin=BeginPosition,end=EndPosition))
+            .rqda$.openfile_gui at widget@widget$SetEditable(FALSE)
+            MarkHere <- .rqda$.openfile_gui at widget@widget$GetBuffer()$CreateMark(mark.name = "MarkHere", where=.rqda$.openfile_gui at widget@widget$GetBuffer()$GetIterAtOffset(BeginPosition)$iter)
             # create a mark -> more reliable to use ScrollToMark than ScrollToIter
-            #gtkTextViewScrollToIter(.rqda$.displayFile at widget@widget,
-            #                          .rqda$.displayFile at widget@widget$GetBuffer()$GetIterAtOffset(BeginPosition)$iter,
+            #gtkTextViewScrollToIter(.rqda$.openfile_gui at widget@widget,
+            #                          .rqda$.openfile_gui at widget@widget$GetBuffer()$GetIterAtOffset(BeginPosition)$iter,
             #                          0.001,xal=0,yal=0,use.align=TRUE)## doesn't seem to work.
-            gtkTextViewScrollToMark(.rqda$.displayFile at widget@widget,
+            gtkTextViewScrollToMark(.rqda$.openfile_gui at widget@widget,
                                       MarkHere,0,xal=0,yal=0.2,use.align=TRUE)
             }    
          CallBackFUN

Modified: pkg/R/GUIHandler.R
===================================================================
--- pkg/R/GUIHandler.R	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/R/GUIHandler.R	2008-12-02 17:50:22 UTC (rev 26)
@@ -30,6 +30,10 @@
 ##                         )
 
 
+add3rdmousepopupmenu(.rqda$.fnames_rqda, AddFileToCaseMenu)
+## right click to add file to a case category
+
+
   addhandlerdoubleclick(.rqda$.fnames_rqda, handler <- function(h,...)
   ##function copied from ViewFileButton handler
   {
@@ -158,5 +162,14 @@
 
 add3rdmousepopupmenu(.rqda$.CasesNamesWidget, CaseNamesWidgetMenu)
 ## popup menu by right-click on CaseNamesWidget
+
+addhandlerclicked(.rqda$.CasesNamesWidget, handler <- function(h,...) {UpdateFileofCaseWidget()})
+
+addhandlerdoubleclick(.rqda$.FileofCase, handler <- function(h,...) {
+ViewFileFun(FileNameWidget=.rqda$.FileofCase)
+HL_Case()
 }
+)
 
+}
+

Modified: pkg/R/root_gui.R
===================================================================
--- pkg/R/root_gui.R	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/R/root_gui.R	2008-12-02 17:50:22 UTC (rev 26)
@@ -35,7 +35,7 @@
   glabel(
 "Author: <ronggui.huang at gmail.com>\n
 License: New style BSD License\n
-Version: 0.1.5 rev 25\n",
+Version: 0.1.5 rev 26\n",
          container=.proj_gui)
 
 
@@ -77,8 +77,12 @@
 #########################
   ".case_pan" <- gpanedgroup(container=.nb_rqdagui,horizontal=FALSE,label="Case")
   ".case_buttons" <- glayout(container=.case_pan)
-  ".CasesNamesWidget" <- gtable("Please click Update",container=.case_pan)
+  ".case_PW" <- ggroup(cont=.case_pan,horizontal = FALSE)
+  ".CasesNamesWidget" <- gtable("Please click Update",container=.case_PW,expand=TRUE,multiple=FALSE)
   .CasesNamesWidget[] <- NULL ; names(.CasesNamesWidget) <- "Cases"
+  ".FileofCase" <- gtable("Please click Update",container=.case_PW,expand=TRUE,multiple=FALSE)
+  .FileofCase[] <- NULL;names(.FileofCase)<-"Files of This Case"
+
   .case_buttons[1,1] <- AddCaseButton()
   .case_buttons[1,2] <- DeleteCaseButton()
   .case_buttons[1,3] <- Case_RenameButton()
@@ -134,6 +138,7 @@
 assign(".codes_rqda",.codes_rqda,env=.rqda)
 assign(".fnames_rqda",.fnames_rqda,env=.rqda)
 assign(".CasesNamesWidget",.CasesNamesWidget,env=.rqda)
+assign(".FileofCase",.FileofCase,env=.rqda)
 assign(".CodeCatWidget",.CodeCatWidget,env=.rqda)
 assign(".CodeofCat",.CodeofCat,env=.rqda)
 assign(".FileCatWidget",.FileCatWidget,env=.rqda)

Modified: pkg/TODO
===================================================================
--- pkg/TODO	2008-12-01 12:50:42 UTC (rev 25)
+++ pkg/TODO	2008-12-02 17:50:22 UTC (rev 26)
@@ -4,13 +4,11 @@
 
 functions cleaning treecode/codecat table. and the previous deletion functions should be modified.
 
-add warning when duplicated file/code etc. are added.
-
 Merge *rqda from different coders.
 
 inter-coder reliability 
 
-assign file to F-cat by pop-up menu.
+change Highlight behavior of Case.
 
 ### less important
 should add document on the table structure.

Added: pkg/man/write.FileList.RD
===================================================================
--- pkg/man/write.FileList.RD	                        (rev 0)
+++ pkg/man/write.FileList.RD	2008-12-02 17:50:22 UTC (rev 26)
@@ -0,0 +1,35 @@
+\name{write.FileList}
+\alias{write.FileList}
+\title{Import a batch of files to the source table}
+\description{
+If import individual file to the project, you can do it by clicking import button in the Files Tab. 
+Sometimes, you want to import a batch of files quickly, you can do it by command. This function is 
+used to import a batch of files into the source table in the *.rqda file.
+}
+\usage{
+write.FileList(FileList, encoding = .rqda$encoding, con = .rqda$qdacon, ...)
+}
+
+\arguments{
+  \item{FileList}{A list. Each element of the list is the file content, and the \code{names(FileList)} are the respective file name.}
+  \item{encoding}{ Don't change this argument.}
+  \item{con}{ Don't change this argument.}
+  \item{\dots}{ \code{\dots} is not used.}
+}
+\details{
+
+}
+\value{
+ This function is used for the side-effects. No value is return.
+}
+\author{Huang Ronggui}
+\examples{
+\dontrun{
+Files <- list("File name one"="content of first File.","File name two"="content of the second File.")
+write.FileList(Files) ## Please launch RQDA(), and open a project first.
+}
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+% \keyword{ ~kwd1 }
+% \keyword{ ~kwd2 }% __ONLY ONE__ keyword per line

Modified: www/ChangeLog.txt
===================================================================
--- www/ChangeLog.txt	2008-12-01 12:50:42 UTC (rev 25)
+++ www/ChangeLog.txt	2008-12-02 17:50:22 UTC (rev 26)
@@ -1,3 +1,8 @@
+2008-12-03
+	* Attached file to case by pop-up menu in Files Tab.
+	* Now can open associated files of a case from Cases Tab.
+	* new function of write.FileList() to import a batch of files.
+	
 2008-12-01
 	* enhance the rename buttons.
 	* bugfix of add buttons: continue only when click confirm in the ginput widget.
@@ -2,2 +7,3 @@
 	* New function write.FileList() to import files by batch.
+	* Enchance the retrieval2 function so coding on the file (openned by clicking back button) is possible.
 	

Modified: www/index.html
===================================================================
--- www/index.html	2008-12-01 12:50:42 UTC (rev 25)
+++ www/index.html	2008-12-02 17:50:22 UTC (rev 26)
@@ -89,14 +89,19 @@
 <br>3. Besides the C-Cat and F-Cat, you can use a trick to help organize files, codes list,and cases by using specific name rules. For example, if you name a group of codes with 1 as prefix and another group of codes with 2 as prefix, then you can click the triangle symbol in ther right-upper corners of the Codes List table, then the codes are sorted according to their prefix. Similar trick applies to others.
 
 <p><b>FAQ</b>
-<br><B>Q</B>:How can I get help?
+<br><B>Q:</B>How can I get help?
 <br>A: You can join the <A HREF="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rqda-help">rqda-help</A> list and post questions via email.
+<br><B>Q:</B>Can I conduct statistical analysis of the codes?
+<br>A: Depends on the method of coding. For factual coding, you can do statisitcal analysis. If the documents are representative, you can do referential analysis; otherwise, you can only conduct descriptive analysis.
+<br><B>Q:</B>Why should I use computer-aided QDA? Is it more efficient?
+<br>A: CAQDA is time-consuming, but it makes the data analysis process more systematic, more tractable, and more transparent. It "forces" you to think hard about your data and the connection with theory (once you know the idea behind the CAQDA). Depending on the methodological paradigms, you may conduct Qualitative Comparative Analysis or examine some hypotheses (Not in the sense of statistical test of hypotheses) (See Kelle 1995 for details).
 
-
 <p>
 <h1>Reference</h1>
+<li> Fisher, M. 1997."Qualitative computing: Using software for qualiative data analysis." Chapter 1. England: Ashgate Publishing Company.
 <li> Kelle, U. (ed.).1995."Computer-aided qualitative data analysis : theory, methods and practice." Sage Publications.
 
+
 <p>
 <h1>How to cite the software</h1>
 <p>Huang Ronggui (2008). RQDA: R-based Qualitative Data Analysis package. R package version 0.1.5. http://rqda.r-forge.r-project.org/



More information about the Rqda-commits mailing list