How to examine the code of a function in R that's object class sensitive

后端 未结 5 691
南笙
南笙 2020-12-07 15:35

I\'m trying to write a function to do a particular job (in my case, analyse a data set for outliers) so the first things I want to do is look at how other people have done s

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 15:39

    When you say

    the function did do other things depending on the class of the object thrown at it

    you are already at the heart of the S3 dispatch mechanism! So I would recommend reading a programming book on R as e.g.

    • (classic but dated) Venables/Ripley "S Programming",
    • Gentleman "Bioinformatics with R",
    • Brown/Murdoch "First Course in Statistical Programming with R",
    • Chambers "Software for Data Analysis: Programming with R",

    or other resources from this SO question on R books along with an example package or two from the rich set of CRAN packages.

提交回复
热议问题