Package 'FreqProf'

Title: Frequency Profiles Computing and Plotting
Description: Tools for generating an informative type of line graph, the frequency profile, which allows single behaviors, multiple behaviors, or the specific behavioral patterns of individual subjects to be graphed from occurrence/nonoccurrence behavioral data.
Authors: Robert Epstein [aut], Thomas Boulier [aut], Ronald E. Robertson [cre, aut], Jonathan Mejia [ctb], AIBRT [cph]
Maintainer: Ronald E. Robertson <[email protected]>
License: GPL-3
Version: 0.0.2
Built: 2025-03-12 04:31:54 UTC
Source: https://github.com/aibrt/freqprof

Help Index


Interpolate multiple columns of a data.frame

Description

Interpolate multiple columns of a data.frame

Usage

approxm(data1, n, method = "linear")

Arguments

data1

a data.frame with columns for interpolation

n

the number of points to interpolate

method

the method to interpolate by, "linear" or "spline"

Value

Returns a data.frame of all data1 variables interpolated to n rows.

See Also

approx is the underlying function and has more options


Correlation test for multiple variables - of the same name - in separate data.frames

Description

Correlation test for multiple variables - of the same name - in separate data.frames

Usage

cor.testm(data1, data2, method)

Arguments

data1

a data.frame with N variables

data2

a data.frame with the same N variables as data1

method

a correlation method, either method = "pearson" or "spearman"

Value

Returns a data.frame of correlation test data for N variables

See Also

cor.test is the underlying function and has more options


Convert data to moving sum/prop.

Description

Convert data to moving sum/prop.

Usage

freqprof(data.behavior, window = round(0.25 * nrow(data.behavior)),
  step = 1, resolution = 1, which = c("sum", "proportion"))

Arguments

data.behavior

a data.frame containing occurrence/nonoccurrence data in binary (0/1) format

window

the window length to use in computing a moving sum or proportion

step

the number of bins of which the data will be translated.

resolution

the number of points contained in a bin

which

giving the moving function to apply: sum or proportion

Value

The data in a freqprof object.

Examples

data(s58)
freqprof(s58)

Generate a sequence of dates

Description

Generate a sequence of dates

Usage

generate_dates(startDate, nDays, by = "day")

Arguments

startDate

a character string in the format "YYYY-MM-DD"

nDays

length of output vector

by

days or weeks

Value

Sequence of dates starting at startDate with length nDays by daily or weekly increments

Examples

generate_dates("2016-06-05", 31, by = "day")

Internal ggplot Wrapper to Graph Frequency Profiles

Description

Internal ggplot Wrapper to Graph Frequency Profiles

Usage

ggplot_fp(data1, resolution = resolution, step = step, yAxis = yAxis,
  xAxisUnits = xAxisUnits, xmin = xmin, xmax = xmax,
  tick.every = tick.every, label.every = label.every)

Arguments

data1

data formated into freqprof class.

resolution

resolution of freqprof data

step

step size of freqprof data

yAxis

a string providing a label for the y-axis.

xAxisUnits

a string indicating which unit has been used. By default, "sec".

xmin

x-axis minimum value

xmax

x-axis maximum value

tick.every

the spacing between each tick. By default, N/30 where N is the number of time units.

label.every

label every X ticks, where X = label.every. By default, label.every = 3.

Value

A ggplot of the frequency profile data in data1


Import Data Pop Up

Description

This function reads a file, whose extension is either csv, bin or fpw, and imports it as a data.frame.

Usage

import_data(filename = file.choose())

Arguments

filename

a string indicating the path of the file containing the data. By default, will open a pop-up so that the user can choose a file with the GUI.

Value

A data.frame ready to be converted into freqprof class (see function freqprof).

Examples

# Only run this example in interactive R sessions
if(interactive()) {
  # Select a file
  import_data()
 }

Kolmogorov-Smirnov test for multiple variables - of the same name - in separate data.frames

Description

Kolmogorov-Smirnov test for multiple variables - of the same name - in separate data.frames

Usage

ks.testm(data1, data2, vars)

Arguments

data1

a data.frame with N variables

data2

a data.frame with the same N variables as data1

vars

a vector of the N variable names

Value

Returns a data.frame with Kolmogorov-Smivnov test data for N variables

See Also

ks.test is the underlying function and has more options.


Internal function for Generating Moving Sum or Proportion

Description

Internal function in freqprof that is used to generate moving sum or proportion data.

Usage

movfun(x, n, s, r, fun)

Arguments

x

data passed from freqprof

n

window length passed from freqprof

s

step size passed from freqprof

r

resolution passed from freqprof

fun

"sum" or "proportion" passed from freqprof

Value

Returns a list containing the processed data into $movfun, and the associated panels into $panels. Passes list to freqprof.


Plot Frequency Profiles.

Description

Use plot_freqprof to plot frequency profile data generated from freqprof.

Usage

plot_freqprof(data.freqprof, yAxis = NULL, xAxisUnits = "sec",
  panel.in = TRUE, panel.out = TRUE, gg = FALSE, multiPlot = FALSE,
  tick.every = round(length(data.freqprof$data$time)/31), label.every = 3)

Arguments

data.freqprof

data formated into class freqprof.

yAxis

a string labelling the y-axis, defaults to data.freqprof$type.

xAxisUnits

a string indicating x-axis units, defaults to "sec".

panel.in

if FALSE the first panel of the frequency profile, the window moving in, is not plotted.

panel.out

if FALSE the third panel of the frequency profile, the window moving out, is not plotted.

gg

if TRUE, will use ggplot2 to plot frequency profiles.

multiPlot

if TRUE, will plot each behavior in its own panel.

tick.every

the spacing between each plot tick mark. By default, N/30 where N is the number of time units.

label.every

label every X ticks, where X = label.every. By default, label.every = 3.

Value

Returns a frequency profiles plot.

Examples

data(s58)
plot_freqprof(freqprof(s58))

Internal function for Resolution Adjustment

Description

Internal function in freqprof that is used to modify data resolution.

Usage

radj(x, r)

Arguments

x

data data passed from freqprof

r

resolution passed from freqprof

Value

Resolution adjustment.


Reads the data in the file "filename", which is supposed to be a .bin file

Description

Reads the data in the file "filename", which is supposed to be a .bin file

Usage

read.bin(filename)

Arguments

filename

a string indicating the path of the file.

Value

A data.frame giving the raw data.

Examples

read.bin(filename = system.file("extdata", "S58-1-1.bin",
                                 package = "FreqProf"))

Reads the data in the file "filename", which is supposed to be a .fpw file

Description

Reads the data in the file "filename", which is supposed to be a .fpw file

Usage

read.fpw(filename)

Arguments

filename

a string indicating the path of the file.

Value

A data.frame of the .fpw data.


Run interactive FreqProf example (Shiny App)

Description

Run interactive FreqProf example (Shiny App)

Usage

runEx()

Examples

# Only run this example in interactive R sessions
if(interactive()) {
  runEx()
}

Occurrence/nonoccurrence data for four behaviors from a single subject

Description

A dataset containing the occurrence/nonoccurence data for four behaviors of a single subject over 3092 observations. Each behavior corresponds to touches on areas of a touchpad.

Usage

s58

Format

A data.frame with 3092 rows and 4 variables

V1

Behavior 1

V2

Behavior 2

V3

Behavior 3

V4

Behavior 4