I am new to R and really need some help. I keep getting the error message
"Error in eff_weights[i, ] <- eff.port$pw : number of items to replace is not a multiple of replacement length"
when I run the loop. Can someone help me figure out what I am doing wrong. Thank you so much in advance!
# Create for loop to find efficient frontier
for (i in 1 : length(grid)) {
eff.port <- portfolio.optim(returns, pm = grid[i], shorts =TRUE)
vector_pm[i] <- eff.port$pm
vector_psd[i] <- eff.port$ps
eff_weights[i, ] <- eff.port$pw
}