similar to: Converting to XTS loses data.frame structure

Displaying 20 results from an estimated 6000 matches similar to: "Converting to XTS loses data.frame structure"

2011 Aug 20
1
Raw epoch time from XTS
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
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
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
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
2017 Sep 16
2
require help
You can just use the same code that I provided before but now use your dataset. Like this df <- read.csv(file="data2.csv",header=TRUE) dates <- as.Date(paste(df$year,"-01-01",sep="")) myXts <- xts(df,order.by=dates) head(myXts) #The last command "head(myXts)" shows you the first few rows of the xts object year cnsm incm wlth
2017 Sep 16
0
require help
oky.. thank you very much to all of you On Sat, Sep 16, 2017 at 2:06 PM, Eric Berger <ericjberger at gmail.com> wrote: > You can just use the same code that I provided before but now use your > dataset. Like this > > df <- read.csv(file="data2.csv",header=TRUE) > dates <- as.Date(paste(df$year,"-01-01",sep="")) > myXts <-
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
2017 Sep 22
2
require help
Assuming the input data.frame, DF, is of the form shown reproducibly in the Note below, to convert the series to zoo or ts: library(zoo) # convert to zoo z <- read.zoo(DF) # convert to ts as.ts(z) # Note: DF <- structure(list(year = c(1980, 1981, 1982, 1983, 1984), cnsm = c(174, 175, 175, 172, 173), incm = c(53.4, 53.7, 53.5, 53.2, 53.3), with = c(60.3, 60.5, 60.2, 60.1, 60.7)),
2010 Jul 09
3
R crashes with large vectors
Good afternoon, I have been experiencing a lot of crashes working with large vectors in R. Specifically, I am using XTS of length of minimum 120k elements. My problem is that I cannot display the vector (otherwise R crashes), I cannot plot it either (otherwise R crashes). That could be solved by reducing the amount of points. However, I have been performing some statistical opreations on is
2017 Sep 16
0
require help
> On 15 Sep 2017, at 11:38, yadav neog <yadavneog at gmail.com> wrote: > > hello to all. I am working on macroeconomic data series of India, which in > a yearly basis. I am unable to convert my data frame into time series. > kindly help me. > also using zoo and xts packages. but they take only monthly observations. > > 'data.frame': 30 obs. of 4 variables:
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.
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,
2017 Sep 15
7
require help
hello to all. I am working on macroeconomic data series of India, which in a yearly basis. I am unable to convert my data frame into time series. kindly help me. also using zoo and xts packages. but they take only monthly observations. 'data.frame': 30 obs. of 4 variables: $ year: int 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... $ cnsm: num 174 175 175 172 173 ... $ incm:
2012 Nov 29
7
Fast Normalize by Group
Hi, I have a very large data set (aprox. 100,000 rows.) The data comes from around 10,000 "groups" with about 10 entered per group. The values are in one column, the group ID is an integer in the second column. I want to normalize the values by group: for(g in unique(groups){ x[group==g] / sum(x[group==g]) } This works find in a loop, but is slow. Is there a faster way to do
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
2010 Mar 28
0
Preserving both yearmon and numeric data in an xls object
Hi R gourmets, I am trying to convert an HTML table into an xts object. The table has six columns, with the data of interest in a single row with each cell containing a long, \n-delimited character string. Initially, I work with these strings as elements in a list. This is necessary because the strings in each cell do not translate into a regular matrix with equal-length columns. Once I fix
2011 Oct 16
1
Read wav file into R
Hi, I'm interested in doing some sound analysis with R. Does anyone have any experience/methods for reading in a wav file? -- Noah Silverman UCLA Department of Statistics 8208 Math Sciences Building Los Angeles, CA 90095 [[alternative HTML version deleted]]
2012 Mar 17
1
plot only non-zero values
Hi, i have some data in a matrix. It has zero values scattered throughout, at random. I'd like to create a line plot, with a line for each row, that *excludes* the zero or NA values. The data looks like this (toy example) 10 12 21 0 23 0 43 0 NA 41 0 0 0 34 35 0 35 0 44 0 NA NA NA 3 2 5 0 3 2 etc... Suggestions on an easy way to do this? Thanks! -- Noah Silverman UCLA Department of
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
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