Dynamic String inputs in knime


#1

Greetings,

Requesting help with an issues with R nodes in Open Source BI Tool KNIME. I want to dyanamically change my URL at runtimw for which i did string manipulations in R and it worked, Script is as below:

x <- ‘https://news.google.com/search?q=
var <- ‘NREGA’
z <- ‘&hl=en-IN&gl=IN&ceid=IN%3Aen’
url <- paste0(x, var,z, collapse = ‘’)

url

Now i want to change this variable(VAR) dynamically and this value will be inputed through a knime node, which in my case is table creator node. I will be putting different value in Table creator so that those can be accessed in R Snippet through ‘knime.in’ . and same can be used to manipulate string in order to get R which then can be used to search Browser and get the result.

Configuration that i tried in R Snippet is as followed in the image

Hope this helps to understand the issue that am facing…

Any other node that can help to get the which can help to get the value of var from a knime node…

Regards
AJ


#2

It has been a while ago since i last worked with the R Snippet Node. But i think your code is not using the input of the Table Creator Node at all (which is what you wanted, right?).
The first line in the script probably even replaces the input from the Table Creator Node (which is knime.in) with the value from the String Input Node (knime.flow.in).
You also again assign the value from the String Input Node to your variable var. So you never really use the input from the Table Creator Node if that was what you were intending to do.

You would have to remove the first row from the script and use an assignment like this:
var <- knime.in$“column1”[0]
or loop through the values of knime.in$“column1” (because it is a collection of the values you inserted in column 1) in your R code to create the individual URLs.

BTW: If all you want is to create URLs with a static and a dynamic part, you can also use the String Manipulation Node after your Table Creator Node. Just use this piece of code:
string(“https://news.google.com/search?q=\”"+$column1$+"\"&hl=en-IN&gl=IN&ceid=IN%3Aen")


#3

Greetings,

Great thannks, :slightly_smiling_face: your suggestion worked,

thanks for the help…

Regards
AJ