How to overcome error:”attempt to set ‘colnames’ on an object with less than two dimension” in xts object You probably want: