Displaying 20 results from an estimated 5000 matches similar to: "Raw epoch time from XTS"
2011 Mar 07
1
Associating the day of week to a daily xts object
I have the following xts objetct "temp"
> str(temp)
An ?xts? object from 2010-12-26 to 2011-03-05 containing:
Data: num [1:70, 1] 2.95 0.852 -0.139 1.347 2.485 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr "t_n"
Indexed by objects of class: [POSIXct,POSIXt] TZ: GMT
xts Attributes:
NULL
> temp
t_n
2010-12-26
2012 May 29
2
Converting to XTS loses data.frame structure
Hello,
I noticed something odd when working with data frames and xts objects.
If I read in a CSV file, R creates a nice data.frame. This works well.
If I then convert to an XTS object, I see that all the values in the data are now quoted. My data is a mix of numeric and character. This is usually seen when converting a data.frame to a matrix, as R will treat all the data as the same class.
2013 May 13
1
Math problem with xts objects
Hello,
I coming across a strange problem doing math on an xts object.
If I have an xts object of stock prices (perhaps 5 minute bars of open, high, low,close) and want to do some math, the results fail.
For example:
d$close[10] - d$open[10] works perfectly
d$close[10] - d$open[9] fails. I just get an answer of "numeric(0) Index: numeric(0)".
My guess is that xts is breaking
2012 Oct 14
4
Date Math
Hello,
I have a time series object (xts) that I iterate over in a loop. Works fine.
My challenge is that I want to be able to reference other entries in the series by math. i.e. For today's observation, what were the last 5 observations? If indexed numerically, it is trivial, but I can figure out how to do this with dates.
This is slightly more difficult as there may not be an
2011 Jun 20
1
access objects by name
Hi,
I have several data structures (xts structures). I then have a list of the names of those objects.
I'd like to access the object by name.
For example:
foo1 <- as.xts(....)
foo2 <- as.xts(...)
foo3 <- as.xts(...)
structs <- c("foo1", "foo2", "foo3")
for (thisOne in structs){
print(thisOne$colA)
}
The above fails. Clearly I'm missing a
2012 Apr 06
1
Converting data frame to its object results in matrix of strings
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
2012 Jun 11
3
Decision Trees or Markov Models for Cost Effectiveness
Hello,
I was just assigned to perform a cost effectiveness study in healthcare. We are studying the cost effectiveness of a proposed diagnostic vs. current screening procedures.
One of the team members suggest a commercial software package called "TreeAge Pro". Looking at the description, it appears to be a nice GUI to some very simple models that could be easily constructed in R.
2012 Oct 09
4
Convert COLON separated format
I have a bunch of data sets that were created for the libsvm tool. They are in "colon separated sparse format".
i.e.
1 5:1 27:3 345:10
Is a row with the label of "1" and only has values in columns 5, 27, and 345.
I want to read these into a data.frame in R.
Is there a simple way to do this?
--
Noah Silverman, M.S.
UCLA Department of Statistics
8117 Math Sciences
2011 Aug 23
0
Ideas for tricky subset of XTS object
Hi,
I have a very large XTS object. It is about 600,000 entries over 1 year time.
I would like to subset a specific piece, by "number of days" not a specific date.
The way I do it now is awkward. Would love to find a way to do this easier to generate a new object just containing the days I want.
---------------------------------------
dayEnds <- endpoints(dataset,
2012 May 18
4
Menus - best practices?
Hello,
I need to design a fairly simple front-end for someone to use an R script system that I've built. My thought was to just use the text based menus available in the base R package, perhaps in some kind of loop.
How have other people done this? Any "best practices" that you can recommend?
Thanks!
--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
2011 Sep 02
2
Avoiding for Loop for moving average
Hello,
I need to calculate a moving average and an exponentially weighted moving average over a fairly large data set (500K rows).
Doing this in a for loop works nicely, but is slow.
ewma <- data$col[1]
N <- dim(data)[1]
for(i in 2:N){
data$ewma <- alpha * data$ewma[i-1] + (1-alpha) * data$value[i]
}
Since the moving average "accumulates" as we move through the data,
2012 May 18
2
Failure building any package
Hello,
I'm attempting to build a package using R 2.15.0 on OS X
I am getting a generic failure when performing a cran type check on the package. Even with a very simple test package, it still fails int he same place.
Example:
In R:
rm(list=ls())
foo <- function(x){print(x)}
package.skeleton(name="foo")
Then, at the command line:
R CMD build foo
R CMD check --as-cran
2012 Feb 28
6
Cleaning up messy Excel data
Unfortunately, some data I need to work with was delivered in a rather messy Excel file. I want to import into R and clean up some things so that I can do my analysis. Pulling in a CSV from Excel is the easy part.
My current challenge is dealing with some text mixed in the values.
i.e. 118 5.7 <2.0 3.7
Since this column in Excel has a "<2.0" value, then R reads the
2011 Aug 23
2
dummy variables from factors
Hi,
Looking at a large data set with many factors.
I would like to expand each factor variable into multiple new variables for each level. (0,1) coding.
My first though was just to code a big nasty loop, to take each level and cbind a column onto my data set. But, that seems painful. There must be a better way.
Is there an "easy" way to do this in R?
(Note, I don't want to
2011 Jan 04
1
XTS : merge.xts seems to have problem with character vectors
Hi,
Please can you tell me what I am doing wrong. When trying to merge two xts
objects, one of which has multiple character vectors for columns...I am just
getting NAs.
> str(t)
POSIXct[1:1], format: "2011-01-04 11:45:37"
> y2 = xts(matrix(c(letters[1:10]),5), order.by=as.POSIXct(c(t + 1:5)))
> names(y2) = c(1,2)
> y2
1 2
2011-01-04 11:45:38
2013 Apr 16
2
Strange error with log-normal models
Hi,
I have some data, that when plotted looks very close to a log-normal distribution. My goal is to build a regression model to test how this variable responds to several independent variables.
To do this, I want to use the fitdistr tool from the MASS package to see how well my data fits the actual distribution, and also build a generalized linear model using the glm command.
The summary
2011 Aug 23
1
Glmnet lambda value choice
Hi,
When using the glmnet() function of the package glmnet, A series of coefficients is returned for a list of descending lambda values.
I am unable to locate anything in the documentation that explains HOW this choice of lambda series is made. (There is documentation about how to choose my own, but I want to understand how the authors are doing it)
Any ideas?
--
Noah Silverman
UCLA
2011 Sep 14
1
Open file for reading and writing with APPEND
Hi,
I want to keep a running file of some statistics generated by a running process. Occasionally the process will be restarted.
On restart, I'd like to read the last line of the log file to set some variables to their last state, and then continue to append values to that same file.
I can't seem to get the appending part to work. I can read values form the file, but then upon the
2017 Oct 06
2
Time series: xts/zoo object at annual (yearly) frequency
Hi,
I'd like to make a time series at an annual frequency.
> a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993"))
Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) :
order.by requires an appropriate time-based object
> a<-xts(x=c(2,4,5), order.by=1991:1993)
Error in xts(x = c(2, 4, 5), order.by =
2011 Mar 04
4
xts POSIXct index format
Hi,
I cannot figure out how to change the index format when displaying POSIXct
objects.
Would like the xts index to display as %H:%M:%OS3 when doing viewing the xts
object.
Think I am missing the obvious.
Cheers,
Chris
--
View this message in context: http://r.789695.n4.nabble.com/xts-POSIXct-index-format-tp3336136p3336136.html
Sent from the R help mailing list archive at Nabble.com.