fromXTStoTS {bimets} | R Documentation

## Convert XTS to TS

### Description

This function transforms a BIMETS compliant `xts()` time series (as defined in `is.bimets`) into a time series of class `ts()`. The core R function `as.ts()` does not satisfy all the requirements of the compliance control check, so it has been extended. Attributes and description of the input time series will be copied to the output time series (see `TIMESERIES`).

### Usage

    fromXTStoTS(x = NULL, avoidCompliance = FALSE, ...)

### Arguments

`x` | Input `xts()` time series that must satisfy the compliance control check defined in `is.bimets`.
`avoidCompliance` | If `TRUE`, compliance control check of input time series will be skipped. See `is.bimets`.
`...` | Backward compatibility.

### Value

This function returns a time series of class `ts()` that has the same observations of the input `xts()` time series.

### See Also

`fromTStoXTS`
`as.bimets`
`is.bimets`
`BIMETS indexing`
`BIMETS configuration`

### Examples

    	#day and month names can change depending on locale
      Sys.setlocale('LC_ALL','C')
      Sys.setlocale('LC_TIME','C')

    	#set configuration BIMETS_CONF_DIP on FIRST
    	setBIMETSconf('BIMETS_CONF_DIP','FIRST');

    	#set configuration BIMETS_CONF_CCT on XTS
    	setBIMETSconf('BIMETS_CONF_CCT','XTS');

    	#semiannual with Date()
    	n=10;
    	xArr=rnorm(n);
    	dateArr=seq(as.Date('2000/07/01'),by='6 months',length=n);
    	dataF=data.frame(dateArr,xArr);
    	xt=xts(dataF[,2],order.by=dataF[,1]);
    	print(fromXTStoTS(xt));

    	#set configuration BIMETS_CONF_DIP on LAST
    	setBIMETSconf('BIMETS_CONF_DIP','LAST');

    	#annual with Date()
    	n=10;
    	xArr=rnorm(n);
    	dateArr=seq(as.Date('2000/12/31'),by='year',length=n);
    	dataF=data.frame(dateArr,xArr);
    	xt=xts(dataF[,2],order.by=dataF[,1]);
    	print(fromXTStoTS(xt));

    	#quarterly with yearqtr()
    	n=10;
    	xArr=rnorm(n+1);
    	dateArr=as.yearqtr('2000 Q2') + 0:n/4;
    	dataF=data.frame(dateArr,xArr);
    	xt=xts(dataF[,2],order.by=dataF[,1]);
    	print(fromXTStoTS(xt));

    	#monthly with yearmon()
    	n=10;
    	xArr=rnorm(n+1);
    	dateArr=as.yearmon('Jul 2000') + 0:n/12;
    	dataF=data.frame(dateArr,xArr);
    	xt=xts(dataF[,2],order.by=dataF[,1]);
    	print(fromXTStoTS(xt));

    	#daily with Date()
    	n=10;
    	xArr=rnorm(n);
    	dateArr=seq(as.Date('2000/07/14'),by='day',length=n);
    	dataF=data.frame(dateArr,xArr);
    	xt=xts(dataF[,2],order.by=dataF[,1]);
    	print(fromXTStoTS(xt));

    	#restore defaults
    	setBIMETSconf('BIMETS_CONF_DIP','LAST');
    	setBIMETSconf('BIMETS_CONF_CCT','TS');

[Package bimets version 1.4.0 Index]