Colonel Panic
Colonel Panic

Reputation: 137544

Read source code of an R function including C

Suppose I'm curious about the workings of the R function, say HoltWinters. I typed HoltWinters and it shows me R source for the function. On inspection, the source shows the function is a wrapper around a second function:

    final.fit <- hw(alpha, beta, gamma)

Presumably, the serious work happens in the function hw. However, I can't find this function anywhere to read its source

> hw
Error: object 'hw' not found

How can I read the source?


Edit: Ok, so now I've read hw , I see it's a wrapper around C_HoltWinters. How can I read that?

Upvotes: 4

Views: 1262

Answers (1)

Julius Vainora
Julius Vainora

Reputation: 48201

As you successfully found, there are lines

hw <- function(alpha, beta, gamma)
    .C(C_HoltWinters,
    ....

in the source of HoltWinters function. Which means that we need to look at C files: you can find all the source code of R here, or just go straight here.

Upvotes: 6

Related Questions