Skip to content
Prev 257193 / 398506 Next

as.Date error

On Apr 17, 2011, at 7:24 PM, Wonjae Lee wrote:

            
cbind.default will return a matrix which needs to have all of its  
elements of the same type, so your dates were coerced to numeric since  
their internal representation is as integers.

Had you created x as a data.frame, then cbind would have called  
cbind.data.frame which was probably what you wanted to happen.

 > xdat <-data.frame(x=as.Date(x,"%m/%d/%Y"))
 > cbind(xdat,y)
            x        y
1 2010-11-16  1753.75
2 2010-11-17 15077.00
3 2010-11-18  1759.35
4 2010-11-19 15078.00