search for: buildtimeseriesfromdataframe

Displaying 2 results from an estimated 2 matches for "buildtimeseriesfromdataframe".

2011 Mar 11
1
dataframe to a timeseries object
...XP, R 2.12.1, latest available packages on CRAN for timeSeries and xts. set.seed(123) N <- 9000 X <- data.frame( ID = c(rep(1,N), rep(2,N,), rep(3,N), rep(4,N)), DATE = rep(as.POSIXct("2000-01-01", tz = "GMT")+ 0:(N-1), 4), VALUE = runif(N*4)) library(timeSeries) buildTimeSeriesFromDataFrame <- function(x, env) { { if(exists("xx", envir = env)) assign("xx", cbind(get("xx", env), timeSeries(x$VALUE, x$DATE, format = '%Y-%m-%d %H:%M:%S', zone = 'GMT', units = as.character(x$ID[1]))), envir = env) e...
2011 Apr 04
3
How to speed up grouping time series, help please
...MT")+ 0:(N-1), K)), VALUE = runif(N*K), stringsAsFactors = FALSE) X <- X[sample(1:(N*K), N*K),] # sample observations to get random order (optional) X <- X[-(sample(1:nrow(X), floor(nrow(X)*0.2))),] # 20% missing head(X, 15) # use explicitly environments to avoid '<<-' buildTimeSeriesFromDataFrame <- function(x, env) { { if(exists("xx", envir = env)) # if exist variable xx in env cbind assign("xx", cbind(get("xx", env), timeSeries(x$VALUE, x$DATE, format = '%Y-%m-%d %H:%M:%S', zone = 'GMT', units = as.ch...