Noah, For me xcoredata() returns a vector of the results, which makes me wonder if you are using an old version of R or your data is somehow stored differently.
Cheers, Josh On Sun, Aug 21, 2011 at 10:15 AM, Noah Silverman <noahsilver...@ucla.edu> wrote: > Josh, > > Good point about including an example. > > calling xcoredata() does work, but only for a *single* row of the data at a > time. In R, I'm used to passing an entire data structure or vector to a > function and automatically getting back a vector of all the results. In this > case, it doesn't work that way. > > The attr() function is probably the best solution. > > Thanks! > > -- > Noah Silverman > UCLA Department of Statistics > 8117 Math Sciences Building > Los Angeles, CA 90095 > > On Aug 20, 2011, at 1:03 AM, Joshua Wiley wrote: > >> Hi Noah, >> >> This is one of those cases where following the posting guide >> (particularly the minimal, reproducible example part) would have >> really helped. Are you saying that calling: >> xcoredata(your_xts_object) does not give you the internal >> representation of time that you want? >> >> data(sample_matrix) >> sample.xts <- as.xts(sample_matrix, descr='my new xts object') >> # returns a list, the index is the numeric representation of time >> displayed in the rows >> xcoredata(sample.xts) >> >> You could also try the more direct: >> >> attr(xts_object, "index") >> >> If this is not what you want or is not working for you, providing us >> the output of dput() from the first few rows of your dataset and an >> example of what you do want would be spectacular. >> >> Cheers, >> >> Josh >> >> On Sat, Aug 20, 2011 at 12:44 AM, Noah Silverman <noahsilver...@ucla.edu> >> wrote: >>> Hi, >>> >>> I have a very large data set stored as an xts object. >>> >>> xts is very nice about showing row labels as "human readable" dates and >>> times. >>> >>> I want the actual epoch values that are stored internally. The only way I >>> can find to access them is one-at-a-time using the internal function: >>> xcoredata() >>> >>> Calling this in an entire column, the "R" way doesn't work. It will only >>> return a single value. Calling it in a loop for each row works but is >>> painfully slow. >>> >>> Since the epoch is stored internally, there must be some way to just grab >>> it as a vector. Does anyone know how? >>> >>> Thanks! >>> >>> -- >>> Noah Silverman >>> UCLA Department of Statistics >>> 8117 Math Sciences Building >>> Los Angeles, CA 90095 >>> >>> ______________________________________________ >>> R-help@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. >>> >> >> >> >> -- >> Joshua Wiley >> Ph.D. Student, Health Psychology >> Programmer Analyst II, ATS Statistical Consulting Group >> University of California, Los Angeles >> https://joshuawiley.com/ > > -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ ______________________________________________ R-help@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.