R Snippet converts integer to numeric

I am having problems with the R Snippet nodes (1:1 and 2:1) converting from integer to double for the output table.

For example, the following bare-bones template will print 'integer' for typeof.  But the output table has double ('numeric' in R).

<rgg>

<![CDATA[

rOut <- read.table("integer_test.txt", sep="\t", head=T)
print(typeof(rOut$id))
rOut

]]>

</rgg>

 

It doesn't appear to be a problem with the R server, as the following code in the R Snippet (Remote), does return integers in the output table:

R<-read.table("integer_test.txt", sep="\t", head=TRUE)
print(typeof(R$id)) # prints 'integer'
R

 

Is there some way to force the R Snippet nodes to return integer type for the output table?

Thanks,

Andrew

 

I am using 2.8.1 on Mountain Lion.

 

 

Hi Andrew,

interesting, I can reproduce this. I thought that you also could configure that in the Script Output tab, but this influences only if KNIME throws warning because of unexpected data type in table. It doesnt change actually the output type at all.

I guess the problem is that your data is loaded within R (and the snippet assumes it has to be double). If the integer data is already input from KNIME then R hands back integer to KNIME. However, I agree there should be a correct interpretation of data type.

We will have a look into this...

Thanks for reporting!

Martin

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