我知道你想要写在Excel与fPortfolio创建投资组合信息的解决方案尝试。我在某处发现了这些代码,它允许我将投资组合信息写入excel(您需要安装xlsx包和java):
## Write output to excel
dir.create("AllPortfolios", showWarnings = FALSE)
mywb <- createWorkbook()
mysheet <- createSheet(mywb, sheetName="Portfolio")
strcol <- 1
mytitle <- data.frame([email protected])
addDataFrame(mytitle , mysheet, startRow=1, startColumn=strcol)
myweights <- data.frame([email protected]@portfolio$weights)
addDataFrame(myweights , mysheet, startRow=3, startColumn=strcol)
strcol <- strcol + 2
mytgret <- data.frame([email protected]@portfolio$targetReturn)
addDataFrame(mytargetreturn , mysheet, startRow=3, startColumn=strcol)
strcol <- strcol + 2
mytgrisk <- data.frame([email protected]@portfolio$targetRisk)
addDataFrame(mytargetrisk , mysheet, startRow=3, startColumn=strcol)
strcol <- strcol + 2
saveWorkbook(mywb, "./AllPortfolios/AllPortfolios.xlsx")
期望的输出是什么? –
我想使用Rexcel在Excel中打印ewPortfolio,它似乎只处理数据框或矩阵对象。 – user1627466
这不回答问题。你想保留哪些信息?排在什么位置?什么列? –