Manova Error: Execute failed: Supporting 'data.frame' as return type, only.

Hi,

When I run this code in R Snippet to obtain the manova function (I know in knime we have the Anova node but there is a bug in it) I get this error:

 

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :

  cannot coerce class "c("manova", "maov", "aov", "mlm", "lm")" to a data.frame

 

 

 

knime.out <- knime.in

data= data.frame(group=factor(knime.in$"Winner Cluster"))

data

y = cbind(knime.in$"Minuti_T", knime.in$"NumeroRilevazioni_T",knime.in$"LatitudineMedia_T")

pippo = manova (y ~ group, data)

pippo

risultato = data.frame(pippo)

knime.out <- risultato

 

 

But if I don't convert pippo in a data frame with     risultato = data.frame(pippo)  I get this error:

 Execute failed: Supporting 'data.frame' as return type, only.

 

So how can I output the result of the manova (I have the right result in "View: R Std Output" but not in "Data Output") in order to connect the output of "View: R Std Output" to the next node?

Thanks

Hi can you try : knime.out<-as.data.frame(pippo)

Thank you very much fabienc. But unfortunately I get the same error:

Error in as.data.frame.default(pippo) :

cannot coerce class "c("manova", "maov", "aov", "mlm", "lm")" to a data.frame

It seems that the function MANOVA is not convertible into a data frame. So how can I extract this information and connect it to the next node?

Thank you

Hi ok I answered too quickly. I can't visualize your problem. So, can you send me sample datas and a reduced workflow ?

From Rsnippet I'd like to extract (to connect to another node) the following table that I can see in "View: R Std Output":

 

                   group Residuals
resp 1          75.79642   7.20358
resp 2          81.16829   1.83171
resp 3          82.12136   0.87864
resp 4          73.17463   9.82537
resp 5          81.32218   1.67782
resp 6          75.56062   7.43938
resp 7          28.25081  54.74919 

Thank you very much fabienc.

 

Hi,

I used an other package to perform the Manova (same results of course). I used the package car. Then I used the str() instruction within the R snippet in order to identify the slots. Finally I casted the lists objects identified by the slots to dataframes and  attributed the knime.out variable to each of the dataframes.

Basically the R code is the following :

library(car)

data= data.frame(group=factor(knime.in$"Winner Cluster"))

y = cbind(knime.in$"B", knime.in$"C", knime.in$"D", knime.in$"E", knime.in$"F", knime.in$"G", knime.in$"H")

pippo = Manova (lm(y ~ group, data))
str(pippo) #helps to identify the slots (for example SSP) by the Eval script function in the Knime's R node
knime.out<-data.frame(pippo$SSP)

As I'm lazy and find the R data manipulations tedious (good for statistics but not really friendly to manipulate the datas). I performed the Manova two times in order to extract the two results.You should do what remains by yourself easily.

Best regards

Hi,

Congrats fabienc! Thank you very much; It works perfectly. If you don't mind I have only another question for you: do you know how to extract the main diagonal of the matrix (that I have as a result of the RSnippet) in a unique row? Is there a node to do this task?

Thank you in advance!

Hi,

well, i'm not very found of R for those things. It will be far more easy in Python in one single step. But I assumed you hadn't a Python installed on your computer to handle it from Knime. So I did it in pure Knime. We should find something less tricky but it's all that came into my mind for the moment. Whatever you want to do with Knime there is always a solution. I hope it is what you intended to do.

Hi,

If you want to test this other version. It should work whatever the size of your original table (except if you have only one column) but only if it is a square matrix of course. And yes, I do agree that this is a little bit too much for what it really does.

Best regards

Wow, fabianc, that really is a lot of stuff you do there. Congrats on all the work, but maybe you focused on one direction too hard? ;)

Here are two simpler ideas for the central part, but lacking some of the housekeeping/decorating. But I still couldn't find a one-step-solution, even with all the java nodes.

Mhh... Excellent! Thanks to you both and congratulations! I think Marlin's workflow is simplier, but in both cases it works :)

Oups ! Yes very simple indeed !

But with my own I learned more ;o)

Thanks