help with R learner node

Hi, I am trying to have the target column passed to the “R learner” node be specified by a “value selection configuration” node. So I created the variable: “target (current value: octane)” and passed it to the “R learner” node.

If I do not use this variable, the following will work in the R script when I specify the target column:
Y = knime.in$“octane” (the column named “octane” is in the column list on the left)

The problem is I cannot figure out how to use the variable to specify this target column. I tried all the following:
Y = knime.in$knime.flow.in[[“target”]]
Y = paste0(“knime.in$”,knime.flow.in[[“target”]])
Y = cat(paste0(“knime.in$”,""",knime.flow.in[[“target”]],"""))

Hi @tnad -

Y <- knime.flow.in[["target"]]

should work. Maybe you need to connect the flow variable in a different way? See attached workflow.

2020-04-13 15_30_38-Overwolf Quick Launcher

RLearnerFlowvarExample.knwf (14.1 KB)

Hi Scott,

The target “octane” is actually in the “column list”, so it needs to be in this form to work: knime.in$“octane”

Y <- knime.flow.in[[“target”]] returns “octane”

I added my workflow to yours which should clear my problem up. This needs the “pls” package in R to run.

RLearnerFlowvarExample_tnad.knwf (871.2 KB)

Ah, I think I understand you now. I believe this is what you want. I just used an intermediate temp variable to hold the value of the flow variable, but it ultimately returns a vector of values:

temp <- knime.flow.in[["target"]]

Y = knime.in[[temp]]
1 Like

That’s it! I’ve been stuck on this for a while :slight_smile:

2 Likes

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