このように出力される未知の R オブジェクトがあります。値を反復処理して出力するにはどうすればよいですか?
print(myRobject)
[[1]]
theTicker thePeriodEnded
"MSFT" "31-03-2013"
theRevenueRaw theNetIncomeRaw
"20489" "6055"
theEarningsPerShareBasicRaw theWeightedAveSharesBasicRaw
"0.72" "8364"
theCashDivDeclPerCommonShareRaw theNetCashFromOperationsRaw "0.23" "9666"
[[2]]
theTicker thePeriodEnded
"XXXX" "31-03-2013"
theRevenueRaw theNetIncomeRaw
"20489" "6055"
theEarningsPerShareBasicRaw theWeightedAveSharesBasicRaw
"0.72" "8364"
theCashDivDeclPerCommonShareRaw theNetCashFromOperationsRaw "0.23" "9666"
ディーンとメトリクス、これがいくつかの結果です。「theTicker」を「MSFT」から分離して、(最終的に) ループできるようにするにはどうすればよいですか?
str(myRobject)
List of 1
$ : Named chr [1:8] "MSFT" "31-03-2013" "20489" "6055" ...
..- attr(*, "names")= chr [1:8] "theTicker" "thePeriodEnded" "theRevenueRaw" "theNetIncomeRaw" ...
myRobject[[1]]
WORKS - returns just list item 1
myRobject[[1]]["theTicker"]
theTicker
"MSFT"
str(myRobject[[1]]["theTicker"])
Named chr "MSFT"
- attr(*, "names")= chr "theTicker"
require(plyr) 必要なパッケージを読み込んでいます: plyr ldply(myRobject, identity)
theTicker thePeriodEnded theRevenueRaw theNetIncomeRaw
1 MSFT 31-03-2013 20489 6055
2 XXXX 31-03-2013 20489 6055
theEarningsPerShareBasicRaw theWeightedAveSharesBasicRaw
1 0.72 8364
2 0.72 8364
theCashDivDeclPerCommonShareRaw theNetCashFromOperationsRaw
1 0.23 9666
2 0.23 9666
アウト[[1]]["theTicker"][1]
theTicker
"MSFT"
アウト[[1]]["theTicker"][2]
<NA>
NA
out[[1]]["theTicker"]["1"]
<NA>
NA
out[[1]]["theTicker"][["1"]]
ERROR
out[[1]]["theTicker"]$1
ERROR
out[[1]]["theTicker"][1,1]
Error in out[[1]]["theTicker"][1, 1] : incorrect number of dimensions
アウト[[1]]["theTicker"][1]
theTicker
"MSFT"
アウト[[1]]["theTicker"][1][1]
theTicker
"MSFT"
out[[1]]["theTicker"][1][2]
<NA>
NA
out[[1]]["theTicker"][1][1][1]
theTicker
"MSFT"
do.call(rbind,myRobject)
theTicker thePeriodEnded theRevenueRaw theNetIncomeRaw
[1,] "MSFT" "31-03-2013" "20489" "6055"
[2,] "XXXX" "31-03-2013" "20489" "6055"
theEarningsPerShareBasicRaw theWeightedAveSharesBasicRaw
[1,] "0.72" "8364"
[2,] "0.72" "8364"
theCashDivDeclPerCommonShareRaw theNetCashFromOperationsRaw
[1,] "0.23" "9666"
[2,] "0.23" "9666"
ticker<-list(myRobject[[1]][1],myRobject[[2]][1])
ティッカー
[[1]]
theTicker
"MSFT"
[[2]]
theTicker
"XXXX"
period<-list(myRobject[[1]][2],myRobject[[2]][2])
period
[[1]]
thePeriodEnded
"31-03-2013"
[[2]]
thePeriodEnded
"31-03-2013"
繰り返しますが、"theTicker" を "MSFT" から分離して、(最終的に) ループできるようにするにはどうすればよいでしょうか?