fawda123 / NeuralNetTools

R package of generic neural network tools
https://fawda123.github.io/NeuralNetTools/
Creative Commons Zero v1.0 Universal
72 stars 20 forks source link

making .nnet a method of plot instead of plotnet #10

Closed bquast closed 8 years ago

bquast commented 9 years ago

As you point out in your article:

https://beckmw.wordpress.com/2013/11/14/visualizing-neural-networks-in-r-update/

the default plotting method for the neuralnet package is not ideal.

Wouldn't it be easier to just name the method

plot.nnet

so that it overrides the included neuralnet plotting method. that way we could just:

plot( neuralnet(...) )
fawda123 commented 9 years ago

I'm not sure if it's possible to override an existing method for a generic function once all the packages are loaded. The order of loading the packages can override generic functions but this doesn't seem to be true for methods. I found a post on StackOverflow (http://stackoverflow.com/questions/13997122/override-s3-methods-in-base-r) that suggests creating a different class to override an existing method, which is kind of relevant to the problem here. It seems simpler from a programming perspective just to create a new generic function that has methods that don't conflict with methods for the same class with another generic.

Method dispatch and namespaces confuse the hell out of me so I'm open to suggestions.