This version principally adds new functionality in the retrieval of codings from a project database. The function takes as arguments the file path to an RQDA project and a string containing a valid SQL query (SQLite flavour). As a default, one does not need to specify the query. The function does this internally to fetch data from relevant tables in the .rqda file. Thus, for a project MyProject.rqda, one can simply call
The default query that is run internally by this function is as follows:
SELECT treecode.cid AS cid, codecat.name AS codecat FROM treecode, codecat WHERE treecode.catid=codecat.catid AND codecat.status=1;
The user is at liberty to form their own queries; a reference for the database tables is in the RQDA package and the documentation for this function (accessed with
?retrieve_codingtable) provides a quick link to that help page. For example, if we want to just collect the filenames of the transcripts used in an analysis, we can use a different query. Note that the data are returned invisibly, to prevent cluttering of the console, so it’s better to bind it to a variable.
qry <- "SELECT DISTINCT name FROM source WHERE status=1;" tbl <- retrieve_codingtable("path/to/MyProject.rqda", qry) tbl
We can easily try this out using material from the excellent RQDA workshop conducted by Lindsey Varner and team. We can download the sample project they used right inside R:
url <- "http://comm.eval.org/HigherLogic/System/DownloadDocumentFile.ashx?DocumentFileKey=101e221b-297e-4468-bfc9-8deccb4adf8c&forceDialog=0" project <- "MyProject.rqda" download.file(url, project, mode = 'wb')
If we check the working directory with
list.files, we should see the project there. Next, using our package’s function, we can get a data frame with information on codings.
> df <- retrieve_codingtable(project) > str(df) Classes ‘codingTable’ and 'data.frame': 39 obs. of 9 variables: $ rowid : int 1 2 3 4 6 9 10 12 13 14 ... $ cid : int 1 1 2 1 2 4 4 1 4 3 ... $ fid : int 2 2 2 2 2 2 3 4 4 4 ... $ codename : chr "Improved Time Management" "Improved Time Management" "Improved Organization" "Improved Time Management" ... $ filename : chr "AEA2012 - Post-Program Interview1" "AEA2012 - Post-Program Interview1" "AEA2012 - Post-Program Interview1" "AEA2012 - Post-Program Interview1" ... $ index1 : num 1314 1398 1688 1087 2920 ... $ index2 : num 1397 1687 1765 1175 2964 ... $ CodingLength: num 83 289 77 88 44 296 120 150 210 116 ... $ codecat : chr "Positive Outcomes" "Positive Outcomes" "Positive Outcomes" "Positive Outcomes" ...
We see that we now created a data frame with 9 columns, with interesting data in them. Note particularly the variables codename, filename, and codecat. Let us now carry out the other query we gave as an example – to get the filenames of all the transcripts in the project:
> qry <- "SELECT DISTINCT name FROM source WHERE status=1;" > tbl <- retrieve_codingtable(project, qry) > tbl name 1 AEA2012 - Post-Program Interview1 2 AEA2012 - Post-Program Interview2 3 AEA2012 - Post-Program Focus Group 4 AEA2012 - Pre-Program Focus Group
This project contains only 4 active files from which all the codings are derived!
A practical point
This function is useful for developing qualitative codebooks, and particularly when coding is carried out inductively and as has been demonstrated, can be extended to other uses, depending on the kind of data that are retrieved.
The easiest way to install the package is from an R session with
# install.packages("remotes") remotes::install_github("BroVic/RQDAassist")
This is a source package, and to build it on Wiindows, Rtools needs to have been properly installed.