I am trying to print values from lists in R.
When I use
cat("Relevant GPD Info for ", endowmentAssetClassVariableNames.v[i],"\n")
I receive the correct list item, e.g. "bbergComm"
,
but if I try to reference an item within that list item, e.g.
cat("Upper Thershold Return: ", paste0(endowmentAssetClassVariableNames.v[i], ".gpdFit$upper.thresh"), "\n")
I only get back
Upper Thershold Return: bbergComm.gpdFit$upper.thresh, and not the value associated with the list item "bbergComm.gpdFit$upper.thresh.
I am running this in a loop, but cannot get my loop to give me the value I am referencing.
What can I do to get the value associated with a list item in a loop?
for(i in 1:length(endowmentAssetClassVariableNames.v)) {
+ cat("Relevant GPD Info for ", endowmentAssetClassVariableNames.v[i],"\n")
+ t<-(paste0(endowmentAssetClassVariableNames.v[i], ".gpdFit$upper.thresh"))
+ cat("Upper Thershold Return: ", paste0(endowmentAssetClassVariableNames.v[i], ".gpdFit$upper.thresh"), "\n")
+ }
Relevant GPD Info for peReturn
Upper Thershold Return: peReturn.gpdFit$upper.thresh
Relevant GPD Info for spReturn
Upper Thershold Return: spReturn.gpdFit$upper.thresh
Relevant GPD Info for hfReturn
Upper Thershold Return: hfReturn.gpdFit$upper.thresh
Relevant GPD Info for wilshireReturn
Upper Thershold Return: wilshireReturn.gpdFit$upper.thresh
Relevant GPD Info for bbergComm
Upper Thershold Return: bbergComm.gpdFit$upper.thresh
Relevant GPD Info for tripleABond
Upper Thershold Return: tripleABond.gpdFit$upper.thresh
all of the gpd objects have the following structure
> str(peReturn.gpdFit)
List of 22
$ n : int 3439
$ data : num [1:3439] -0.1582 -0.0892 -0.0873 -0.0762 -0.0662 ...
$ upper.exceed : num [1:344] 0.0298 0.0721 0.0558 0.0201 0.0402 ...
$ lower.exceed : num [1:344] -0.0513 -0.0358 -0.0428 -0.0205 -0.0332 ...
$ upper.thresh : Named num 0.0165
..- attr(*, "names")= chr "90%"
$ lower.thresh : Named num -0.0161
..- attr(*, "names")= chr "10%"
$ p.less.upper.thresh : num 0.9
$ p.larger.lower.thresh: num 0.9
$ n.upper.exceed : int 344
$ n.lower.exceed : int 344
$ upper.method : chr "ml"
$ lower.method : chr "ml"
$ upper.par.ests : Named num [1:2] 0.0108 0.1451
..- attr(*, "names")= chr [1:2] "lambda" "xi"
$ lower.par.ests : Named num [1:2] 0.0119 0.07
..- attr(*, "names")= chr [1:2] "lambda" "xi"
$ upper.par.ses : logi NA
$ lower.par.ses : logi NA
$ upper.varcov : logi NA
$ lower.varcov : logi NA
$ upper.info : logi NA
$ lower.info : logi NA
$ upper.converged : logi TRUE
$ lower.converged : logi TRUE
- attr(*, "class")= chr "gpd"
I am looking to extract some of the gpd object values in a loop where I assign names associated with the object.