Learn R Programming

itsadug (version 2.0)

timeBins: Label timestamps as timebins of a given binsize.

Description

Function for calculating timebins.

Usage

timeBins(x, binsize, pos = 0.5)

Arguments

x
Numerical vector with timestamp information.
binsize
Size of the timebin, measured in the same units (often ms) as x.
pos
Numerical value that determines the label of the binsize as proportion of the binsize. A value of 0 will provide the minimum timestamp within the bin as label, a value of 1 will provide the maximum value within the bin as label. Defaults to 0.5, the ce

Value

  • Anumerical vector of the same size as x with timebin information.

See Also

Other Utility functions: convertNonAlphanumeric, diff_terms, findAbsMin, find_difference, find_n_neighbors, getDec, getRange, group_sort, list2str, missing_est, move_n_point, print_summary, se, summary_data

Examples

Run this code
data(simdat)
# grouping Time values in bins:
simdat$Timebin <- timeBins(simdat$Time, 200)
head(simdat)

# different labels:
simdat$Timebin2 <- timeBins(simdat$Time, 200, pos=0)
head(simdat)

Run the code above in your browser using DataLab