def R_bool(py_bool):
    """Convert python bool (True/False) to a string that can be read as a bool
    by R (TRUE/FALSE/NA)"""
    if py_bool == None:
        return 'NA'
    if py_bool:
        return 'TRUE'
    elif not py_bool:
        return 'FALSE'
    else:
        return 'NA'