[R] look at the underlying source code

R. Michael Weylandt michael.weylandt at gmail.com
Sat May 19 22:49:40 CEST 2012


That means it calls compiled C code so you'll need to download the
source code from CRAN to see it. It will be somewhere in the
rugarch/src/ directory, but you'll have to find it manually or with a
good editor/IDE -- you're out of R now.

The primitive() means that .C is itself a primitive function (more or
less that means built into the R interpreter directly) -- don't worry
about that. Look instead for "sgarchsimC" in the .c files.

Best,
Michael

On Sat, May 19, 2012 at 3:28 PM, jaimie villanueva
<jaimie.villanueva at gmail.com> wrote:
> Michael
> i was doing what you told me and everything seems to go alright, until i
> face with one problem.
> I dont know how can i get access to the function ".C("sgarchsimC")"
> I dont know exactly what is the so called .Primitive() and how can i get
> into.
> I started with following instructions:
>
>> getMethod("ugarchsim","uGARCHfit")
>> getAnywhere(.sgarchsim)
>> getAnywhere(.sgarchsim1)
>
>> getAnywhere(.C("sgarchsimC"))
>    A single object matching ‘.C’ ‘sgarchsimC’ was found
>    It was found in the following places
>    package:base
>    namespace:base
>    with value
>
>    function (.NAME, ..., NAOK = FALSE, DUP = TRUE, PACKAGE, ENCODING)
>  .Primitive(".C")
>   Warning message:
>    In find(x, numeric = TRUE) :
>   elements of 'what' after the first will be ignored
>
> i feel that i'm pretty near.
> Do you have any idea??
>
>
> 2012/5/19 jaimie villanueva <jaimie.villanueva at gmail.com>
>>
>> thank's a lot Michael.
>> Is exactly what i was looking for.
>>
>> regards
>> Jamie
>>
>> 2012/5/19 R. Michael Weylandt <michael.weylandt at gmail.com>
>>
>>> Unfortunately the task is slightly harder here -- ugarchsim calls a
>>> network of S4 code that is a little hard to trace....
>>>
>>> You can get started by typing
>>>
>>> getMethod("ugarchsim", "uGARCHfit")
>>>
>>> to see the first step which calls a variety of functions with names like
>>>
>>> .sgarchsim
>>>
>>> You'll have to read a line of code here that uses switch so it's a
>>> little harder to follow if you've never used that construct before
>>> than method dispatch or if/then might be.
>>>
>>> It looks like these are not exported so you'll have to use
>>>
>>> getAnywhere(.sgarchsim)
>>>
>>> to start following those. It looks like that in turn calls .sgarchsim1
>>> or .sgarchsim2 which are the end of the line and should help you out.
>>>
>>> Hope this helps,
>>> Michael
>>>
>>> On Fri, May 18, 2012 at 2:16 PM, Rui Barradas <ruipbarradas at sapo.pt>
>>> wrote:
>>> > Hello,
>>> >
>>> > There are two simple ways,
>>> >
>>> > 1. Type  the function name without parenthesis at an R prompt;
>>> > 2. Download the source from CRAN or R-Forge, R is open source.
>>> >
>>> > Hope this helps,
>>> >
>>> > Rui Barradas
>>> >
>>> > jaimie villanueva wrote
>>> >>
>>> >> hi
>>> >>
>>> >> someone can show me how can i get the source code of a function. Is a
>>> >> S4
>>> >> class or Method. (I'm not an expert in R environment)
>>> >> Exactly, Function "ugarchsim" from library (rugarch).
>>> >> I need to know (in detailed ) how the variance and  mean ecuation of a
>>> >> arma/garch process are calculated.
>>> >> With other packages like "fGarch" i used to invoked the function debug
>>> >> ()
>>> >> and allows me to step into the functions but with ugarchsim i can't
>>> >> use
>>> >> it.
>>> >>
>>> >> any suggestions are well received
>>> >>
>>> >> thanks
>>> >>
>>> >> Jamie
>>> >>
>>> >>       [[alternative HTML version deleted]]
>>> >>
>>> >> ______________________________________________
>>> >> R-help@ mailing list
>>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>>> >> PLEASE do read the posting guide
>>> >> http://www.R-project.org/posting-guide.html
>>> >> and provide commented, minimal, self-contained, reproducible code.
>>> >>
>>> >
>>> >
>>> > --
>>> > View this message in context:
>>> > http://r.789695.n4.nabble.com/look-at-the-underlying-source-code-tp4630532p4630538.html
>>> > Sent from the R help mailing list archive at Nabble.com.
>>> >
>>> > ______________________________________________
>>> > R-help at r-project.org mailing list
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide
>>> > http://www.R-project.org/posting-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>



More information about the R-help mailing list