[R] Converting data frame to its object results in matrix of strings
R. Michael Weylandt
michael.weylandt at gmail.com
Fri Apr 6 22:10:53 CEST 2012
Try this:
x <- xts(as.character(1:10), Sys.Date() + 0:9)
storage.mode(x) <- "double"
Michael
On Fri, Apr 6, 2012 at 1:13 PM, Noah Silverman <noahsilverman at ucla.edu> wrote:
> Hi,
>
> I have a rather large data frame (500 x 5000) that I want to convert to a proper xts object.
>
> I am able to properly generate an xts object with the correct time index. However, all of my numerical values are now strings.
>
> b <- as.xts(a[,2:dim(a)[2]], order.by=as.POSIXct(strptime(paste(a$Date), '%m/%d/%Y')))
>
> My guess is that somewhere in the large data frame there are a few strings hiding that is causing the who thong to be converted to string.
>
> Is there some way to force the as.xts function to ignore the strings and keep everything numeric?
>
>
> Thanks!
>
>
> --
> Noah Silverman
> UCLA Department of Statistics
> 8208 Math Sciences Building
> Los Angeles, CA 90095
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list