目标:我正在尝试查找67种货币到美元的货币转换。
数据:以下是货币清单:
currency <-c("ALL", "AMD", "AZN", "BIF", "BOB", "BRL", "BZD", "CLP", "CNY",
"COP", "CRC", "DOP", "EGP", "EUR", "GEL", "GHS", "GTQ", "HNL",
"HTG", "IDR", "ILS", "INR", "JOD", "KES", "KGS", "KHR", "LAK",
"LBP", "LRD", "LSL", "MDL", "MGA", "MMK", "MNT", "MWK", "MXN",
"MZN", "NAD", "NGN", "NIO", "NPR", "PEN", "PHP", "PKR", "PYG",
"RWF", "SBD", "SLL", "SRD", "SSP", "THB", "TJS", "TRY", "TZS",
"UAH", "UGX", "USD", "VND", "VUV", "WST", "XAF", "XCD", "XOF",
"YER", "ZAR", "ZMW", "ZWD")
我做了什么:
使用getQuote
库中的quantmod
函数,我能够获得大部分报价,如下所示:
#Split list of 67 currencies into groups of 10
from_chunks <- split(currency),
ceiling(seq_along(currency)/10))
#Get length of each group
length_chunks <- lapply(from_chunks,length)
#Make a vector of length equalt to from_chunks with desired currency USD.
to_chunks <- lapply(length_chunks,rep,x="USD")
#Function that takes many currencies and converts them to one
quote_batches <- function(from,to){
return(quantmod::getQuote(paste0(from, to, "=X")))
}
#Apply to the entire list
mapply(quote_batches,from_chunks,to_chunks)
问题:我遇到的问题以及将67种货币分成10组的原因是并非所有的块都在运行。块5和7给出了这个错误:
Error in `.rowNamesDF<-`(x, value = value) : invalid 'row.names' length
为什么呢?请告知:)
答案 0 :(得分:2)
<div class="portlet" ng-repeat="news in newsList">
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption">
{{ news.title }}
<small>{{ news.subtitle }}</small>
</div>
<div class="actions">
<a class="btn btn-info btn-sm" href="{{ url('news_edit', {id: news.id}) }}">
<i class="fa fa-pencil"></i> Editer
</a>
</div>
</div>
<div class="portlet-body">
<img ng-if="news.image" src="{{ news.image }}" class="pull-left" height="100"/>
<div ng-bind-html="news.shortContent"></div>
</div>
</div>
</div>
和SSP
都会产生404错误。试试吧:
ZWD
您可以使用循环
轻松找到它quantmod::getQuote("SSP=X")
quantmod::getQuote("ZWD=X")