Data conditioning for pems data

Description

Various functions for the conditioning of pems objects.

Usage

1
2
3
4
5
cutBy(ref = NULL, ..., data = NULL, cut.method = NULL, 
        labels = NULL, fun.name = "cutBy", hijack= FALSE)

cutByRow(ref = NULL, n = 4, rows = NULL, ..., data = NULL,  
        fun.name = "cutByRow", hijack= FALSE)

Arguments

ref

(Data series typically vector) The reference data series to consider when making a vector of subset markers/indices. See Details.

...

(Optional) Other arguments, currently passed on to pems.utils management functions.

data

(Optional data.frame or pems object) The data source if ref is supplied in either a data.frame or pems object.

cut.method

(Optional function) For cutBy only, the method to use when cutting ref. If not supplied, cutByRow used by default.

labels

(Character vector) For cutBy only, a vector of names to be assigned to the cut regions.

fun.name, hijack

(Various managment arguments) fun.name is the name of the parent function, to be used in error messaging. hijack is a logical) that developers can use to locally 'hijack' this function. See Note on hijack below.

n, rows

(numerics) n sets the number of equal intervals to attempt to cut the data into. rows sets the exact rows at which to cut the data at. If n is applied and the length of ref is not exactly divisible by n a best attempt is made. If both n and rows are set, rows is applied.

Details

cutBy and cutBy... functions generate a vector of subset markers or indices based of the type of cut applied and the range/size of the reference, ref. See Value regarding outputs.

cutBy is a wrapper for other cutBy... functions. It provides additional options for cut.marker naming.

cutByRow assigns cut regions based in row number.

Value

By default results are returned as pems.elements.

The cut.marker vector generated by cutBY and cutBy... functions can then be used to condition and subsample data in pems objects.

Warning

Currently, no warnings.

Note

hijack is an in-development argument, supplied to allow code developers to run multiple functions in different function environments. When developers 'mix and match' code from several sources it can become unstable, especially if functions are run within functions within functions, etc. hijack = TRUE and associated code makes a function local to 'side-step' this issue. This work by assuming/expecting all inputs to be local, i.e. supplied directly by the code user.

Various other cutBy... options can be very simply encoded.

Author(s)

Karl Ropkins

References

References in preparation.

See Also

cut, etc. in the main R package.

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
###########
##example 1 
###########

#basic usage

#working with a temporary pems

temp <- pems.1

#cut into equal subsets

temp$ref <- cutBy(velocity, n= 5, data=temp)

pemsPlot(local.time, velocity, cond=ref, data=temp, 
             type="l", layout=c(1,5))

#cut at three points

temp <- pems.1
temp$ref <- cutBy(velocity, rows=c(180,410,700), data=temp)

pemsPlot(local.time, velocity, cond=ref, data=temp, 
             type="l", layout=c(1,5))