[rkward-devel] rkwarddev

meik michalke Meik.Michalke at uni-duesseldorf.de
Mon Jan 30 15:55:19 UTC 2012


hi mischa,

Am Montag, 30. Januar 2012 14:40:46 schrieb Mischa Vreeburg:
> How can access the file location of .rkwardrc and the file location of the
> scriptfile from R engine, from within a plugin for the purpose of either
> reading or writing to these files?

what do you mean be "the scriptfile"? does ?normalizePath help?

if you are referring to rk.plugin.skeleton() from rkwarddev, the function has 
a single return value, which is the root path to the directory to which all 
plugin files are written. there is no present feature to get all individual 
file names this way, but you can of course scan that with dir() etc.

> How do I set options within the plugin from an R object. ie. I have an
> object 'setting something' which is true. I want to pick this up when
> running the plugin, without having to select something first.

can you give an exact example?

>  How do I use the rkward dev fuction ite for dropdown boxes selection in
> the generated javascripts , to test for id = value?

ok, than one i can answer ;-)

let's take a dropdown menu from the cluster analysis plugin:

  require(rkwarddev)
  clust.h.drop.dist <- rk.XML.dropdown(label="Computation method",
    options=list(
      "Euclidean"=c(val="euclidean", chk=TRUE),
      "Maximum"=c(val="maximum"),
      "Manhattan (city block)"=c(val="manhattan"),
      "Canberra"=c(val="canberra"),
      "Binary"=c(val="binary"),
      "Minkowski"=c(val="minkowski")
    ))

the object named "clust.h.drop.dist" now contains the dropdown menu labeled 
"Computation method". you can examine the resulting XML code by calling it on 
the R console:

  > clust.h.drop.dist
  <dropdown id="drp_Cmpttnmt" label="Computation method">
    <option label="Euclidean" value="euclidean" checked="true" />
    <option label="Maximum" value="maximum" />
    <option label="Manhattan (city block)" value="manhattan" />
    <option label="Canberra" value="canberra" />
    <option label="Binary" value="binary" />
    <option label="Minkowski" value="minkowski" />
  </dropdown>

as you can see, it was automatically given the ID "drp_Cmpttnmt", since no 
custom id.name was specified. if you need this ID for anything, the function 
id() can extract both the XML ID and the JavaScript variable name, which can 
be different:

  > id(clust.h.drop.dist, js=FALSE)
  [1] "drp_Cmpttnmt"
  > id(clust.h.drop.dist)
  [1] "drpCmpttnmt"

basically, id() collapses a comma seperated list of several XML and character 
objects into one string, while replacing the XML objects with the respective 
ID value:

  > id("the JS name is: ", clust.h.drop.dist)
  [1] "the JS name is: drpCmpttnmt"

let's assume what we want is, if the option "minkowski" was chosen from the 
dropdown list, we also want to define a second value by this spinbox:

  clust.h.spin.pwmink <- rk.XML.spinbox(label="Power of Minkowski distance",
    min=1, initial=2, real=FALSE)

now, in the JavaScript section, if we want to check whether the dropdown value 
is "minkowski" and then have the value of the spinbox echoed to the options of 
our R function call, ite() can be used like this:

  ite(
    id(clust.h.drop.dist, " == \"minkowski\""),
    echo(", p=", clust.h.spin.pwmink)
  )

echo() creates a JS version of itself, also replacing XML objects with IDs, so 
in the actual JavaScript file, the above will be evaluated as:

  if(drpCmpttnmt == "minkowski") {
    echo(", p=" + spnPwrfMnkw);
  }

again, you can see the above JS result of the ite() call if you run it in the 
console, so you can quickly examine if the outcome looks right.

> How do I get from the rkward dev functions something like this if ( !xxx )
> logic in the generated javascripts and for  if(xxx =>< y) logic in
> javascripts

hm, here again i'm not so sure what you mean... but generally, ite() in 
combination with id() can produce all of this.

hope this helps.


viele grüße :: m.eik

-- 
  dipl. psych. meik michalke
  abt. f"ur diagnostik und differentielle psychologie
  institut f"ur experimentelle psychologie
  heinrich-heine-universit"at d"usseldorf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20120130/44406907/attachment.sig>


More information about the Rkward-devel mailing list