r'''Returns the thermal conductivity of a substance given its R-value,
    which can be in either SI units of m^2 K/(W*inch) or the Imperial units
    of ft^2 deg F*h/(BTU*inch).

    Parameters
    ----------
    R_value : float
        R-value of a substance [m^2 K/(W*inch) or ft^2 deg F*h/(BTU*inch)]
    SI : bool, optional
        Whether to use the SI conversion or not

    Returns
    -------
    k : float
        Thermal conductivity of a substance [W/m/K]

    Notes
    -----
    If given input is SI, it is divided by 0.0254 (multiplied by 39.37) and
    then inversed. Otherwise, it is multiplied by 6.93347 and then inversed.

    Examples
    --------
    >>> R_value_to_k(0.12), R_value_to_k(0.71, SI=False)
    (0.2116666666666667, 0.20313787163983468)

    >>> R_value_to_k(1., SI=False)/R_value_to_k(1.)
    5.678263341113488

    References
    ----------
    .. [1] Gesellschaft, V. D. I., ed. VDI Heat Atlas. 2nd edition.
       Berlin; New York:: Springer, 2010.

def R_value_to_k(R_value, SI=True):
    r'''Returns the thermal conductivity of a substance given its R-value,
    which can be in either SI units of m^2 K/(W*inch) or the Imperial units
    of ft^2 deg F*h/(BTU*inch).

    Parameters
    ----------
    R_value : float
        R-value of a substance [m^2 K/(W*inch) or ft^2 deg F*h/(BTU*inch)]
    SI : bool, optional
        Whether to use the SI conversion or not

    Returns
    -------
    k : float
        Thermal conductivity of a substance [W/m/K]

    Notes
    -----
    If given input is SI, it is divided by 0.0254 (multiplied by 39.37) and
    then inversed. Otherwise, it is multiplied by 6.93347 and then inversed.

    Examples
    --------
    >>> R_value_to_k(0.12), R_value_to_k(0.71, SI=False)
    (0.2116666666666667, 0.20313787163983468)

    >>> R_value_to_k(1., SI=False)/R_value_to_k(1.)
    5.678263341113488

    References
    ----------
    .. [1] Gesellschaft, V. D. I., ed. VDI Heat Atlas. 2nd edition.
       Berlin; New York:: Springer, 2010.
    '''
    if SI:
        r = R_value/inch
    else:
        r = R_value*foot**2*degree_Fahrenheit*hour/Btu/inch
    return thermal_resistivity_to_k(r)