How to read excel file in R Snippet

,

Hi Knimers!

I want to use an excel database in the R snippet, I tried to open the excel file with kIn, but it didn’t work. I figured out how to add the flow variables but couldn’t find the solutions to this problem.

Thanks

You could have a look at this example and modify it.

Examples to import single files to R could be this, and they might be modified.

3 Likes

There is now a version specifically with an Excel file


My workflow looks like this after the insert column header i want to run the excel trough the r snippet, but i just can’t open it in the snippet. this is my exact problem.

Your R Snippet looks like the one from the community integration which requires Rserve to be started manually maybe you could try with the ‘official’ R integration:

Then I do not understand what it is you want to do in the R Snippet. Maybe you could provide us with a working example reproducing the error or describe in more details what you want to do. Your R Snippet get input from KNIME so I do not see when Excel comes into play. Maybe you could elaborate further.

1 Like

Sorry for the lack of details. So first of all i have program in R which is convert laboratory datas into categories. I do it manually and now i want to automate it and don’t want to rewrite the whole program, just use the important parts. Excel is important cause it contains the laboratory datas for me.

I tried to refer to the excel as, “LabData<-importBufferedDataTable()” but it didn’t work. As you mentioned, the R snippet gets the input from Knime , but i can’t refer to it and also Rserve ran in the background.

I still have a hard time understanding your problem. Once the data is there from excel in KNIME you should be able to easily transfer it to R. You could reuse your current R cond within the snippet you would just have to switch out the input and output data port. The line to import data should look something like this:

LabData <- knime.in

If you want to directly address the excel file from R there was the mentioned example with readxl.

I tried the LabData <- knime.in and get an error message: Error in try({ : object ‘knime.in’ not found.

There are two kinds of R snippets. One is from the community which you seem to be using the other one is the ‘official’ one from KNIME. knime.in and knime.out is the ‘style’ of the official one. You should try that.

Then you might want to create a minimal reproducible example where the error occurs so we might investigate further.

1 Like

Okay, i will try it with offcial and check back with the results. Thanks for your help.

1 Like

Hello,
The solution was the official R , and after some debugging in the code now it’s works finally.

Thanks!

2 Likes