Neither of these show the source code of pnorm function,
stats:::pnorm
getAnywhere(pnorm)
How can i see the source code of pnorm?
sum
(..., na.rm = FALSE) .Primitive("sum")
.Primitive("sum")
function (..., na.rm = FALSE) .Primitive("sum")
methods(sum)
no methods were found
and, how can I see source code of the sum function?
The R source code of
pnormis:So, technically speaking, typing "pnorm" does show you the source code. However, more usefully: The guts of
pnormare coded in C, so the advice in the previous question view source code in R is only peripherally useful (most of it concentrates on functions hidden in namespaces etc.).Uwe Ligges’s article in R news, Accessing the Sources (p. 43), is a good general reference. From that document:
(Emphasis added because the precise function you asked about (
sum) is covered in Ligges’s article.)Depending on how seriously you want to dig into the code, it may be worth downloading and
unpacking the source code as Ligges suggests (for example, then you can use command-line tools
such as
grepto search through the source code). For more casual inspection, you can viewthe sources online via the R Subversion server or Winston Chang’s github mirror or the R-svn github mirror (links here are specifically to
src/nmath/pnorm.c). (Guessing the right place to look,src/nmath/pnorm.c, takes some familiarity with the structure of the R source code.)meanandsumare both implemented in summary.c.