Hi

I am unable to try out examples from the Rmetrics Ebook from the R command
prompt. Below is an example of what happens:

> Covariance<-cov(SWX.RET)
Error in cov.timeSeries(SWX.RET) :
  no slot of name "Data" for this object of class "timeSeries"

I have loaded Rmetrics and fPortfolio using the library function but still I
get these errors.

However, if I embed the R code into a C program  like below it works. Why is
this happening? I'm very confused.

Program:

#include <Rinternals.h>
#include <Rembedded.h>

int main (int argc, char** argv) {

    SEXP e,val;
    int errorOccurred;

    Rf_initEmbeddedR(argc, argv);

    PROTECT(e = lang2(install("library"), mkString("fPortfolio")));
    R_tryEval(e, R_GlobalEnv, NULL);
    UNPROTECT(1);

    PROTECT(e = lang2(install("cov"), install("SWX.RET")));

    val = (R_tryEval(e, NULL, &errorOccurred));


    Rf_PrintValue(val);

    return 0;

}

Output:

R version 2.9.1 (2009-06-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Loading required package: MASS
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: fCopulae
Loading required package: sn
Loading required package: mnormt
Package 'sn', 0.4-4 (2007-10-08). Type 'help(SN)' for summary information
Loading required package: adapt
Loading required package: fAssets
Loading required package: robustbase

Attaching package: 'fAssets'


    The following object(s) are masked from package:fCopulae :

     .mvstFit

Loading required package: quadprog
Loading required package: Rglpk
Loading required package: slam

Attaching package: 'slam'


    The following object(s) are masked from package:timeSeries :

     colMeans,
     colSums


    The following object(s) are masked from package:base :

     colMeans,
     colSums,
     rowMeans,
     rowSums

Using the GLPK callable library version 4.37
Loading required package: Rsymphony
               SBI           SPI          SII          LP25          LP40
SBI   1.685150e-06 -4.146820e-06 1.353892e-07 -1.075973e-07 -9.441923e-07
SPI  -4.146820e-06  1.175681e-04 6.599240e-07  2.203762e-05  3.616704e-05
SII   1.353892e-07  6.599240e-07 9.032237e-06  2.706275e-07  4.108008e-07
LP25 -1.075973e-07  2.203762e-05 2.706275e-07  6.463869e-06  9.927796e-06
LP40 -9.441923e-07  3.616704e-05 4.108008e-07  9.927796e-06  1.577805e-05
LP60 -2.064749e-06  5.463615e-05 6.150988e-07  1.463853e-05  2.372445e-05
              LP60
SBI  -2.064749e-06
SPI   5.463615e-05
SII   6.150988e-07
LP25  1.463853e-05
LP40  2.372445e-05
LP60  3.609053e-05



Thanks

Abhijit Bera

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to