def METHOD_NAME(self, nb):
    """
    Filter out cells in an R notebook with syntax errors.
    """
    new_cells = []
    for cell in nb["cells"]:
        if cell["cell_type"] == "code":
            source = "\n".join(get_source(cell))
            valid_syntax = R_PACKAGES["ottr"].valid_syntax(source)[0]
            if valid_syntax:
                new_cells.append(cell)
    nb = copy.deepcopy(nb)
    nb["cells"] = new_cells
    return nb