Cannot find optimal weights under PortfolioAnalytics package

funds <- colnames(R)
init.portf <- portfolio.spec(assets=funds)
init.portf <- add.constraint(portfolio=init.portf, type="weight_sum", min_sum=1, max_sum=1)
init.portf<- add.constraint(portfolio=init.portf, type="box", min=0, max=1)
init.portf <- add.objective(portfolio=init.portf, type="return", name="mean")
init.portf <- add.objective(portfolio=init.portf, type="risk", name="StdDev")

maxSR.lo.ROI <- optimize.portfolio(R=R, portfolio=init.portf, 

Here's my code. When I cut my data in a part of columns like R <- R[,1:8], it works. But If I use all columns to run the code, all optimal weights show NA and warning that

'In optimize(f = sharpe_obj_fun, R = R, constraints = constraints,  ... :NA/Inf replaced by maximum positive value'.

Thanks for helping!