asOf: Function to recover the current data.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Creates a vector of current data as of a specified date.

Usage

1
 asOf(x, currentDate) 

Arguments

x

Object of the accrued class.

currentDate

The current date of interest.

Details

A column matrix of data current as of the specified date is returned. The row names are the dates. For dates prior to the currentDateNum minus the maximal accrual lag, the final value is used.

Value

None.

Author(s)

Julie Eaton and Ian Painter

See Also

data.accrued, stackedUploadData, uploadPattern, plot.accrued, plot.summary.accrued, lagHistogram, barcode

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	data(accruedDataExample)	# simulated accrued data
	testData <- data.accrued(accruedDataExample)	
	currentData <- asOf(testData)
	plot(currentData)
	currentData <- asOf(testData, currentDate=20) # If dates are indexed from 1.
	plot(currentData)

	testData <- data.accrued(accruedDataExample, start="2010-04-20")	
	currentData <- asOf(testData, currentDate="2010-07-12") 
	L = dim(currentData)[1] 
	yMax = max(currentData[,1], na.rm=TRUE) + 100
	num_labels = round(L/4,0)
	y_tick_places = seq(0, yMax, by=round(yMax/num_labels,0))
	x_indices = 1:L
	x_tick_places = x_indices[(0:num_labels)*3]
	x_labels = dimnames(currentData)[[1]][(0:num_labels)*3]
	plot(currentData[,1], axes=FALSE, xlab="", ylab="Current counts", ylim=c(0,yMax))
	abline(h=0)
	abline(v=0)
	axis(1, at=x_tick_places, labels=x_labels, las=2 )
	axis(2, at=y_tick_places, labels=y_tick_places, las=2 )
	
	## Not run: 
	library(animation)
	# Requires a separate application called "ImageMagik"

		NROW = nrow(testData[["data"]])
		saveGIF({
			for( R in 1:NROW ) {
				plot( 	c(0, NROW+1), 
						c(0, max(dat[["data"]], na.rm=TRUE)), 
						type='n', xlab='day', ylab='count' )
				currentValues = asOf(testData, currentDate=R)	
				points(1:R, currentValues)
				lines(1:R, currentValues, col='lightblue')
			}
		}, cmd.fun=system, interval=0.1)
	
## End(Not run)

	
	


Search within the accrued package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.