araastat/reprtree

Impossible to plot the tree

Opened this issue · 2 comments

Hello !

I tried to use the function reprtree:::plot.getTree(my_model) but it is not working and I have the following message:
"Error in row.names<-.data.frame(*tmp*, value = strtoi(x, 2)) :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': "

I tried to display my trees with the following lines of code:
rf11_100<-randomForest(Bid~., data=df11, ntree=100, proximity=TRUE)
reprtree:::plot.getTree(rf11_100,3,labelVar=TRUE)

(3 is just to get the display of the tree number 3).

Let me know if you need anything else.

Thanks for your help !

Visign

I have exactly the same issue! But still no luck in finding a solution!

migli commented

I have the same error.
I narrowed it down to the as.tree function which invokes the following line:

row.names(fr) <- strtoi(x, 2)

For reasons that I don't fully understand, x ends up having 32 binary digits.
This ends up in an integer overflow for strtoi which simply returns NA. Since I'm having more than one NA, assigning it to names will trigger the duplicate error.

Here is an example of what I mean:

strtoi("11101100111010000101010011011100", 2)
# [1] NA

I'd suggest converting it to decimal instead in order to avoid integer overflow. But I'm not sure if the integer type is required down the hill.