Flow Variable in R Plot nodes

Hi there,

 

looping over several data columns (type=double), I use R to render histograms (generic R plot node). Is there anyway I can use a flow variable (e.g. the col header that would be passed a variable name) as my histogram title ?

 

thanks.

bruno

Using the new R (Interactive) nodes, you can do something like the snippet below to make a metanode that has a user configurable scatter plot.

# This example relies on ggplot2 and grid, if these packages are not part of 
# your R installation, please add them!
require(ggplot2)
require(grid)

# Select data accoding to quicforms here. 

x 		= knime.in[knime.flow.in[["x"]]]
y 		= knime.in[knime.flow.in[["y"]]]
pcolor 	= knime.in[knime.flow.in[["color"]]]
pshape 	= knime.in[knime.flow.in[["shape"]]]


# Retype for ggplot2
xn = as.numeric(as.matrix(x)) 
yn = as.numeric(as.matrix(y))
colorf = as.factor(as.matrix(pcolor))
shapef = as.factor(as.matrix(pshape))


# define a plot theme
# http://docs.ggplot2.org/0.9.2.1/theme.html for more options
clean_theme = theme(panel.background = element_blank(),
				panel.border = element_rect(color = "black", linetype = "solid", fill = "transparent"),
				axis.title.x = element_text(size=14, face="italic", colour = "black"),
				axis.title = element_text(size=14, face="italic", colour = "black"),
				axis.text = element_text(size=12, face="italic", colour = "black"),
				legend.text = element_text(size=12, face="italic", colour = "black"),
				panel.grid = element_blank()
				)

# Generate a plot and apply the theme
qplot(xn, yn, color = colorf, shape = shapef, xlab = knime.flow.in[["x"]], ylab = knime.flow.in[["y"]], main = knime.flow.in[["title"]]) + clean_theme	

 

Aaron, thanks for the information. looks good.

I tried, but got some red ink message in the interactive R view console (vide infra)

"ERROR     R View (Table) 

Execute failed: R_HOME does not contain a folder with name "bin".
R_HOME is meant to be the path to the folder which is the root of Rs installation tree.
It contains a bin folder which itself contains the R executable.
Please change the R settings in the preferences."

 

I tried to fix this issue by changing the config, browsed to the R home folder...I've got all my R nodes working but these ones 're not (spent quite a bit of time on this-only, though)

Any additional clue would be more than welcome. I'll try again tomorrow, browsing the internet formum about this R Home thing.

Edit. this is happening with my Mac (osX) not with my W7 laptop.

thanks.

bruno

Are you using the standard or interactive R nodes?  On my mac, R_Home is set to:

/Library/Frameworks/R.framework/Versions/3.0/Resources

for the R (Interactive) nodes

Please see my final comment in this message thread.
"KNIME (eclipse-java) process disappears when trying to instantiate R in R(Interactive) nodes" 

The R interactive nodes install with a /usr/bin as R_HOME instead of the one you specified above which is the R_HOME variable in a standalone R environment.

Setting this incorrectly causes no end of trouble, as the thread above chronicles.

Can this please be documented somewhere in the FAQ so that Mac users do not keep running into this problem and have to debeg the problem?

-- Scott

Scott,

thank you for the support. Im sorry that i did not see your post before bothering everybody.
will investigate and let you know. it's true however that the default behavior for preference install is different Mac vs Windows and misleading...having got it right at once in window let me thought I would have got it right as once as well unde OSX...nah! too easy...

bruno

Aaron,

the issue depicted here are related to the interactive R nodes. For what it's worth, I've uninstalled all the R framework, restart and re install again.

  • path to my R install is : /Library/Frameworks/R.framework/Versions/3.0/Resources/bin/R
  • pref r home is /Library/Frameworks/R.framework/Versions/3.0/Resources.

Tonight, I've got a new red message from the interactive Rnode view(table):


R cannot be intialized.
Only R in version 2.x is supported. The R installation defined in the preferences is of version 3.x.
You can fix the problem by pointing to a valid R v2 installation or by
 - uninstalling the feature "org.knime.features.rengine.r2"
 - modifying your R installation and adding the package "rJava" (available from CRAN)
 - add a line to knime.ini: -Djava.library.path=<R-install-folder>/library/rJava/jri/x64
   (path printed to console while running install.packages("rJava") in R)
and restarting KNIME.

I'll give a try to the above suggestion from the node console...basically redoing what Scott has posted bellow...I missed that post down there btw)

FYI, other R nodes e.g.

  • community >R Scripting > generic (I do not use them so I cant tell)
  • community > R scripting R plot and snipets are ok
  • knime  lad > R (interactive) > R to Table (e.g.) generates the issue at hand
  • R nodes > remote > ok with my local host on the default port
  • R  nodes > local > e.g. table R view is ok.

thanks for the time and support. will keep you posted.

bruno

Aaron, Scott,

Well, looks like this was meant to be a long evening...

  • did all what was recommended by either Aaron, Scott or the red message from the nodes. (see above)
  • install the suitable rJava packages (got the rJava 0.9-6)
    • noticed that there is not indeed any way I can get to locate the x64 thing in here
  • even went on the R support to read abour R.home()...good tip btw

I got a new red message from the nodes, only much more straight forward...

R cannot be intialized.
Cannot load JRI native library

just giving up for tonight.

thanks

bruno