I just started using Python resp. Rpy2 so I am really a beginner.
So far I manage to get my own R-package loaded via Rpy2
and a result for my input variables is produced (comparable
to the lm() function of R).
My result is a following:
>>> res
<ListVector - Python:0x1561828 / R:0xe6a5c8>
[Matrix, Array]
coef.f: <class 'rpy2.robjects.vectors.Matrix'>
[-10.554713, 1.640681, 0.957045, ..., 0.000000, 0.000000, 0.783108]
pred.f: <class 'rpy2.robjects.vectors.Array'>
[17.189366, 7.116058, 41.526062, ..., 459.952946, 312.088634, 677.908581]
I am also able to get the array subpart (pred.f) by using index 1:
>>>res1 = res[1]
>>> res1
<Array - Python:0x1561850 / R:0x4b299d0>
[17.189366, 7.116058, 41.526062, ..., 459.952946, 312.088634, 677.908581]
>>> print res1
, , L=300, AR=1.5, SO=1, T=30
sigma_stat sigma_mob
fit 17.189366 152.21461
lwr 7.116058 76.98245
upr 41.526062 301.01379
, , L=300, AR=1.5, SO=2, T=30
sigma_stat sigma_mob
fit 27.62310 284.5423
lwr 14.54639 173.3316
upr 52.45825 467.1449
, , L=300, AR=1.5, SO=3, T=30
sigma_stat sigma_mob
fit 39.75894 459.9529
lwr 24.07098 312.0886
upr 65.67369 677.9086
Now I’d like to use a intelligent way to access certain numbers in this array.
Eg. I’d like the number for sigma_stat,fit,L=300,AR=1.5,SO=3,T=30 … this means
my array is 6-dimensional.
Is there an easy way to do that? Something like indexing using the dimension names/numbers: res1(‘sigma_stat’,’fit’,’L’=300,’AR’=1.5,’SO’=3,’T’=30)
Thank you for your help…
Would something like this work ?
(note that the dimension names must in the right order – I don’t that the time to test, may be ‘sigma_stat’ and ‘fit’ should go to the end of the argument list)