Project

General

Profile

Actions

Bug #4010

open

RExpression2 - tracking for backwards compatibility

Added by ben leinfelder almost 15 years ago. Updated about 14 years ago.

Status:
New
Priority:
Normal
Category:
actors
Target version:
Start date:
04/21/2009
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
4010

Description

This bug is meant to help identify and track differences between the script-based (original) RExpression actor and the JRI-based RExpression2 actor

Actions #1

Updated by ben leinfelder almost 15 years ago

1. Numbers are converted to ArrayTokens of numbers when going from JRI -> Ptolemy. This is a JRI quirk/feature in that all numeric assignments are done with arrays - even if there's only a single value.
Solution: Remove the Token from the ArrayToken as the last step in the conversion process if it is an ArrayToken with only one element.
Drawback: what if we really did intend for it to be an array with a single value?

Actions #2

Updated by ben leinfelder almost 15 years ago

I've gone through the existing R demos (now in modules/r/demos/R) and tested them with the RExpression2 actor in place of the original class. The following workflows presented errors (that i'll now work on resolving):

BEAM_4_1.xml
-JRI crashes Kepler
-script works
*noticed that it seems to use load(".RData") - might have something to do with it

eml_Table_as_Record_R.xml
-JRI fails due to pairs() error
-script works

multiport-dataframe-union-R.xml
-JRI fails due to pairs() error
-script works

R_output_example.xml
-JRI fails (type incompatible with array plotter)
-script fails (class cast exception)

ReadTable.xml
-JRI problems with plotting (perhaps conversion to dataframe?)
-script based version works fine

RExpression_Dataframe_Test.xml
-JRI version fails because it returns an array of length 1 (by default) for the double token value that the test is expecting.
-script-based version works as before

RExpression_Matrix_IO_Test.xml
-JRI incorrectly converts the Ptolemy matrix token

sampling_occurrenceData_ R.xml
-JRI crashes kepler

Actions #3

Updated by ben leinfelder almost 15 years ago

FIXED:
RExpression_Matrix_IO_Test.xml
-matrices now handled like R wants them to be (column-major)

Actions #4

Updated by ben leinfelder almost 15 years ago

ReadTable.xml

there's a issue with how I'm setting up the graphics device. it's purely my R code, since the following R session shows the same error:

pdf(file = 'ReadTable1.pdf',width = 6.666666666666667, height = 6.666666666666667)
species <- c(1,2,3)
ccnt <- c("a","b","c")
plot(species,ccnt)

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

Actions #5

Updated by ben leinfelder over 14 years ago

Testing JRI with the SANParks TPC workflows. Because of how the R code is sent to JRI and executed, we have to do some parsing of the script before sending "lines" of code to the JRI library. So far these are the problems that I've encountered:

-comments need to be stripped out. this is easy for lines that are comprised completely of comments but is tricky when the # character appears inside a quoted string (valid in R). I seem to have a good regex to handle most cases of this correctly (but it's still something to watch for as the R code gets more and more advanced)

nested code (if/else, function definitions, etc...) that use {} need to be consolidated into a single "line" but with each statement delimited by ; i have it working for this coding style:
if (true) {
i <
1
}
else {
i <- 2
}
but need to support alternate syntax like:
if (true) {
i <- 1
} else {
i <- 2
}

-function calls or other code that can be broken into multiple lines for readability are not currently supported - that means lines can get very wide (and copying and pasting formatted valid R code from your favorite editor can break it big time)

Actions #6

Updated by Oliver Soong over 14 years ago

With regards to Comment #5, why not just write the script to file, then have JRI eval a source command. R will handle all the parsing. From there, you should be able to use the same old methods to get and export R objects to tokens.

Actions #7

Updated by ben leinfelder over 14 years ago

just:
source(filename)
you think?

Actions #8

Updated by Oliver Soong over 14 years ago

Yup. It should parse and eval the file in .GlobalEnv as if it were typed in interactively. I don't think we need any of the advanced options at the moment.

Actions #9

Updated by ben leinfelder over 14 years ago

That works!

Actions #10

Updated by Oliver Soong over 14 years ago

One question that I'm not sure of. Are created variables being cleaned between instances of R? Variable passing should only occur through tokens, no?

Actions #11

Updated by ben leinfelder over 14 years ago

all the objects are removed when the next R actor starts to [re]use the "R engine" so only objects sent through tokens exist in the next R actor

Actions #12

Updated by Tom Parris about 14 years ago

Ben ... sorry to ask stupid questions (SQs).

SQ1: I just removed R 2.9.0 from my system and now have R 2.10.1. How do I change the Kepler definition of R_HOME to match.

SQ2: I'm assuming that the way to get to RExpression2 is to add the regular RExpression to a workflow and than change the class path ro RExpression2. Correct?

Thanks. I have some specific tests that I'll run regarding treatment of matrices (and large ones at that).

Cheers,
Tom

Actions #13

Updated by ben leinfelder about 14 years ago

Stupid Responses (SRs):
SR1 - you can change the "environment.txt" file in the r module to reflect the correct R_HOME value for your system. THe default values are:
R_HOME:Mac OS X=/Library/Frameworks/R.framework/Resources
R_HOME:Windows=C:\Program Files\R\R-2.9.0
R_HOME:linux=

I'd be cautious changing this with the RExpression2 actor since JRI is very closely tied to the R version running on your system. You may quickly find a version mismatch error (or, because of how Java->native libraries work, you may just crash Kepler when you first run with RExpression2 and the JRI library is built for a different version). Let us know what happens! and good luck!

SR2 - It's best to "Instantiate" the RExpression actor from the menu bar rather than editing the actor on the canvas. I know you can hand edit the full class name in the MOML file of your workflow and then open it in Kepler, but that is a hassle and prone to typos. Use the menu option, definitely.

Actions #14

Updated by Tom Parris about 14 years ago

First ... apologies. I just submitted an RExpression bug that you've already fixed in Rexpression2 (column major matrices).

SR2 - It's best to "Instantiate" the RExpression actor from the menu bar rather
than editing the actor on the canvas. I know you can hand edit the full class
name in the MOML file of your workflow and then open it in Kepler, but that is
a hassle and prone to typos. Use the menu option, definitely.

OK. Getting ready to test with R-2.10.1, but not sure I understand SR2 above (and this may be related to why I am still having problems with matrices). If I search for RExpression in the "Search Components" box, the only actor I get is RExpression (no RExpression2). So the only way I can get to RExpression2 is to instantiate it from the Tools menu. When I do that, I get a bunch of character escaping errors due to Windows style back slashes.

Error in png(filename = "C:Usersparris.keplercache-2.0.0modules\rR_Matrix_Test_1266958503103RExpression1.png", :
unable to start device
In addition: Warning messages:
1: \U used without hex digits
2: '\p' is an unrecognized escape in a character string
3: '\.' is an unrecognized escape in a character string
4: '\c' is an unrecognized escape in a character string
5: '\m' is an unrecognized escape in a character string
6: '\R' is an unrecognized escape in a character string
7: '\R' is an unrecognized escape in a character string

If I change the specification of the working directory for the actor to use forward slashes, I get the same problem.

Actions #15

Updated by Redmine Admin about 11 years ago

Original Bugzilla ID was 4010

Actions

Also available in: Atom PDF