summary.FemFit: Summarise the events of a FemFit Object

Description Usage Arguments Details Value See Also Examples

View source: R/summary.FemFit.R

Description

A summary method for segmented "FemFit" objects.

Usage

1
2
3
4
5
6
## S3 method for class 'FemFit'
summary(x, response = c("zeroPrssr", "prssr_sensor"),
  descriptives = list(pfmc3x5s_rest30s = list("Lin.Trend"), rapid_pfmc15s =
  list("Count+Peak"), two_and_triple_cough_rest10s = list("Max"),
  valsalva3x6s_rest30s = list("Lin.Trend")), toPrint = TRUE,
  sprintf_Format = "%4.2f", ...)

Arguments

x

An "FemFit" object.

response

Specifies which response to work with when calculating the descriptives. Must be set to "zeroPrssr" or "prssr_sensor".

descriptives

A list object containing the descriptives to calculate for each event within a JSONLabel. See Details.

toPrint

A logical constant which controls whether to print the summary output.

sprintf_Format

A character constant which formats the numeric output the printed summary output.

...

Other arguments not used by this method.

Details

The "FemFit" object must be segmented to have events within the protocol information. That is, the trLabel column has "event" entries within the JSONLabels of interest.

The list object for descriptives is formatted such that the name of the JSONLabel is associated with the list of descriptives to generate for the events within the JSONLabel. Options that are provided by summary are:

toPrint and sprintf_Format only uses the first element if there is a vector input.

Value

Silently returns a tibble object.

See Also

sprintf for possible formatting options to apply to numeric output.

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
AS005 = read_FemFit(c(
        "Datasets_AukRepeat/61aa0782289af385_283_csv.zip",
        "Datasets_AukRepeat/61aa0782289af385_284_csv.zip"
    ),
    remove.NAs = TRUE
  ) %>%
  # Segment the FemFit data
  segment(
    cp. = 0.001,
    numOfNodesToLabel = list(c(3, 1, 3, 4), c(4, 1, 5, 3))
  ) %>%
  # Calculate the zeroed out pressures
  deriveZero(method = "lmm")

# Extract the descriptives with the default arguments
summary(AS005)

# An example of specifying descriptives
summary(AS005, descriptives = list(
  "rapid_pfmc15s" = list("Lin.Trend", "Count+Peak", "Count+PeakBySensor"))
)

# Define a function to extract the median pressure of an event trace
medianWrap = function (x) {
  # The `toPrint` element tells `summary.FemFit` what to print
  # Whereas the `toReturn` element which is a `list` object, tells `summary.FemFit` what to silently return.
  dplyr::tibble(toPrint = median(x), toReturn = list(median(x)))
}

# Define a function to extract the robust regression linear trend
library(MASS)
Robust.Lin.Trend = function (x) {
  # Append the time component in ms to the vector
  x.df = data.frame(x = x, time = 0:(length(x) - 1) * 10)

  # Fit the linear model with robust regression
  x.fit = MASS::rlm(x ~ time, data = x.df)

  # Print the coefficient in terms of a second change rather than a ms change
  # Return the intercept and linear trend coefficients with their std. errors
  dplyr::tibble(toPrint = 1000*coef(x.fit)[2], toReturn = list(summary(x.fit)$coefficients[, 1:2]))
}

# An example of specifying a user-defined function to generate a descriptive
# Instead of supplying a character input, a list input is used
# The list has three elements
  # The first is the function used to generate the descriptive
  # The second tells `summary.FemFit` whether to apply by sensor all to all sensors
  # The third tells `summary.FemFit` what to name the descriptive
summary(AS005, descriptives = list(
  "pfmc3x5s_rest30s" = list(
      "Lin.Trend",
      list(medianWrap, bySensor = TRUE, name = "Median"),
      list(Robust.Lin.Trend, bySensor = TRUE, name = "Robust Lin.Trend")
  )
)

TheGreatGospel/FemFit documentation built on May 21, 2019, 9:19 a.m.