2 ms·
Really, syntax "nba.head(1)" is not any more "object-oriented" than "head(nba, 1)" -- it's just syntax, and the R statement is in fact an application of R's obj
by xixi77 11y ago
Really, syntax "nba.head(1)" is not any more "object-oriented" than "head(nba, 1)" -- it's just syntax, and the R statement is in fact an application of R's object system (there are several of them).
IMO, R's system is actually more powerful and intuitive -- e.g. it is fairly straightforward to write a generic function dosomething(x,y) that would dispatch specific code depending on classes of both x and y.
- illumen 11y agoSingle-dispatch generic functions are easy in python too: https://www.python.org/dev/peps/pep-0443/ https://www.python.org/dev/peps/pep-0443/
- xixi77 11y agoThat's good to know, thanks :) Although, for single dispatch, the S3 system of R is kinda hard to beat -- you just name your function print.myclass and you are done :)