# the plugin code was generated by this script # you should not change the plugin code directly, but this script # note: this script only creates objects in your workspace, # *EXCEPT* for the last call, see below. # set the output directory to overwrite the actual plugin output.dir <- tempdir() overwrite <- TRUE require(rkwarddev) about.info <- rk.XML.about( name="rk.CohenKappa", author=c( person(given="Meik", family="Michalke", email="meik.michalke@hhu.de", role=c("aut","cre"))), about=list(desc="RKWard GUI to calculate Cohen's Kappa, i.e., the agreement of two raters (using the psych package)", version="0.01-0", url="http://rkward.sf.net"), dependencies=list(rkward.min="0.5.6"), package=list(c(name="psych")) ) ############ ## cohen's kappa ############ kappa.var.select <- rk.XML.varselector(label="Select data") kappa.var.data <- rk.XML.varslot(label="Data (matrix or data.frame, 2*n or p*p)", source=kappa.var.select, classes=c("data.frame", "matrix"), required=TRUE) kappa.var.weights <- rk.XML.varslot(label="Weight matrix (p*p)", source=kappa.var.select, classes="matrix") kappa.spin.nobs <- rk.XML.spinbox(label="Number of observations (if data is a square matrix)", min=0, real=FALSE) kappa.spin.alpha <- rk.XML.spinbox(label="Alpha value for confidence interval", min=0, max=1, initial=0.05) save.results <- rk.XML.saveobj("Save results to workspace", initial="kappa.result") kappa.full.dialog <- rk.XML.dialog( rk.XML.row( kappa.var.select, rk.XML.col( kappa.var.data, kappa.var.weights, rk.XML.stretch(), rk.XML.frame(kappa.spin.nobs, kappa.spin.alpha), save.results ) ) , label="Cohen's Kappa") ## JavaScript kappa.js.calc <- rk.paste.JS( echo("\tkappa.result <- cohen.kappa("), ite(kappa.var.data, echo("\n\t\tx=", kappa.var.data)), ite(kappa.var.weights, echo(",\n\t\tw=", kappa.var.weights)), ite(id(kappa.spin.nobs, " > 0"), echo(",\n\t\tn.obs=", kappa.spin.nobs)), ite(id(kappa.spin.alpha, " != 0.05"), echo(",\n\t\talpha=", kappa.spin.alpha)), echo("\n\t)\n\n") ) kappa.js.print <- rk.paste.JS( echo("\trk.header(\"Correlation coefficients and confidence boundaries\", level=3)\n"), echo("\trk.print(kappa.result[[\"confid\"]])\n"), echo("\trk.print(paste(\"<b>Alpha level:</b>\", kappa.result[[\"plevel\"]]))\n"), echo("\trk.print(paste(\"<b>Number of subjects:</b>\", kappa.result[[\"n.obs\"]]))\n\n") ) ############# ## if you run the following function call, files will be written to tempdir! ############# # this is where it get's serious, that is, here all of the above is put together into one plugin rk.plugin.skeleton( about.info, path=output.dir, xml=list( dialog=kappa.full.dialog), js=list(results.header="Cohen's Kappa and weighted Kappa", require="psych", calculate=kappa.js.calc, printout=kappa.js.print), pluginmap=list(name="Cohen's Kappa", hierarchy=list("analysis")), create=c("pmap", "xml", "js", "desc"), overwrite=overwrite, tests=FALSE, # edit=TRUE, load=TRUE)#, # show=TRUE)