Your answer sums up to one, but what allowed some weight to be more than one is that you did not limit your weight to positive. If this is what you want, you need to add one constraint to the variable. It works:
dr <- matrix(runif(100*7), 100, 7)
Following your comments on the possibility of a short one, it now sounds like your variables should be limited to -1 and 1. Then use:
amat <- t(rbind(matrix(1, ncol = n), c1, c2, diag(n), -diag(n))) bvec <- c(1, 0.35, 0.35, rep(-1, n), -rep(1, n)) solve.QP(dmat, dvec, amat, bvec, meq)
source share