如何在R中嵌入/执行excel VBA宏? 我在SUB以下,我希望从R控制台执行。
Sub splitinto99()
Dim X As Long, LastRow As Long, vArrIn As Variant, vArrOut As Variant
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
vArrIn = Range("A1:A" & LastRow)
ReDim vArrOut(1 To 24, 1 To Int(LastRow / 24) + 1)
For X = 0 To LastRow - 1
vArrOut(1 + (X Mod 24), 1 + Int(X / 24)) = vArrIn(X + 1, 1)
Next
Range("B1").Resize(24, UBound(vArrOut, 2)) = vArrOut
End Sub
答案 0 :(得分:0)
我得到它将概率放在列和&不使用VBA的行。通过创建列表和for循环。
probs <- seq(.01,.99,.01)
wlm <- plm <- list()
for(i in seq_along(probs)){
wlm[[i]] <- lm(Zonal.Price~.-ZONEID-timestamp,data=train9)
plm[[i]] <- predict(wlm[[i]],newdata=test9)
}
write.csv(plm,"predlm.csv")