partOfDay: Code data into different parts of day

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

Description

This function returns the part of day from time stamps. The day can be split into parts of different length with a chosen start time for the splits.

Usage

1
partOfDay(time, nsplit = 4, start = 1)

Arguments

time

Timestamp vector in POSIXct format

nsplit

Number of splits.

start

Start time of the split in hours (1-24)

Details

It is often useful to observe the amount of behaviors during different part of day e.g. if we want to find out how different behaviours are distributed over the entire day. This function returns the part of day from time stamps. The function returns only even hours, if nsplit provides intervals with decimal hours they will be rounded to nearest integer.

Value

A factor with the part of day for input timestamps with hour intervals as labels-

Author(s)

Matti Pastell <matti.pastell@helsinki.fi>

See Also

hour, hourly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#Look at the daily distribution of feed intake of cows
#in dataset RIC
data(RIC)
data <- clean.RIC(RIC)
#With default split
data$period <- partOfDay(data$begin)
#Plot the results
boxplot(intake~period,data=data,ylab='Feed intake (kg)',
xlab='Time of day',main='Default settings: start =1, nsplit=4')
#A different split with directly plotting the result
boxplot(intake~partOfDay(begin,nsplit=6,start=3),data=data,
ylab='Feed intake (kg)',xlab='Time of day',main='start=3,nsplit=6')

Animal documentation built on May 2, 2019, 5:48 p.m.