Learn R Programming

POSSA (version 0.6.5)

get_p: Extract p-value from tests

Description

This function attempts to extract p values from certain tests where it could otherwise be complicated to do so. Please make sure, in case of each new test, whether the function actually returns the values you want.

Usage

get_p(x)

# S3 method for aov get_p(x)

# S3 method for aovlist get_p(x)

Value

Returns either a single p value or, in case of multiple p values, a list or nested list with each p value.

Arguments

x

Test results.

Methods (by class)

  • get_p(aov): get_p method for class 'aov'

  • get_p(aovlist): get_p method for class 'aovlist'

Details

Supported functions: all tests that return the p value as p.value (including most R stats test functions, having htest class), and the aov() function (aov and aovlist classes).

Examples

Run this code

get_p(t.test(extra ~ group, data = sleep))
# returns 0.07939414
# same as printed via t.test(extra ~ group, data = sleep)

get_p(prop.test(c(83, 90, 129, 70), c(86, 93, 136, 82)))
# returns 0.005585477,
# same as printed prop.test(c(83, 90, 129, 70), c(86, 93, 136, 82))

get_p(aov(yield ~ block + N * P * K, npk))
# returns list of p values
# corresponds to summary(aov(yield ~ block + N * P * K, npk))

get_p(aov(yield ~ N * P * K + Error(block), npk))
# returns nested list of p values (effects per error term)
# again corresponds printed p values via summary()

Run the code above in your browser using DataLab