process map output in R

Hello everyone,

So I have created a process map using R for a sample dataset. I have also placed the code in the R View node. Currently, the map gets outputted locally on my computer but I would like to connect the image output directly into another KNIME node. For example, the image output widget. I am confused as to how exactly can I get the map to go into the image output of the R-View node. Since process maps are not graphs, I can’t use the plot command in R . It would be great if someone can help me out. Thanks!

Hi @RijinM and welcome to the KNIME community forum

Maybe this previous post by @stelfrich could shed some light on how to solve your problem:

Hope it helps.

Best
Ael

1 Like

Hi,
Thank you for your help! I tried the workflow posted but is there a way of directly outputting an image rather than a plot from the R-View node. Because, the R code output that I have is a process map which is an image and does not have x,y, or title so I can’t use qplot, or plot commands in general as that give me an error in KNIME.

@RijinM maybe you could give us an example what kind of graphic is being produced. Maybe a small workflow without any secret data.

You could use the png() command from within the R node but that might als involve plotting.

library(Cairo)

# https://stackoverflow.com/questions/24999983/r-unable-to-start-device-png-capabilities-has-true-for-png
png(my_path,width=1024,height=768, bg = "transparent", type="cairo")
plot.new

# your plot here

dev.off()

You also can handle images that are on your drive if they are SVG or PNG and bring them back into KNIME and work further with them:

2 Likes

Thank you for your help! For my workflow, I just have a csv reader → R_View → image output widget.

In terms of what kind of graphic is being produced from my R View node, an example of this can be found here:ggplot2 - Creating Process Map Diagrams using different packages in R - Stack Overflow

The issue I am facing is how can I get this graphic as an actual image output so it can be passed into the next node in KNIME. Right now, I have a render_graph command in my script which renders this graph somewhere on my computer. I can’t seem to access the location. I tried other commands in R such as export_graph but that doesn’t seem to work. If I try plotting it, I get the following error since the map is not a plot
image

Hi @RijinM

@mlauber71 provided in another post a solution for what I believe the solution you need. The R code is the following:

which you can find in the solution posted by @mlauber71 at the following link:

I tried it and the only thing i needed to change (because I’m working on Windows) is the way the folder separator is coded (from // to \). The fully run version compatible with windows is available from the following link:

k_001_r_export_data.knwf (232.0 KB)

Please have a look at the -R- code inside the -R- nodes of this workflow which I believe should solve your problem.

Hope it helps,
Ael

2 Likes

Thank you for your help!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.