at the expense of efficiency, added proper NA handling to as_atom and as_typed_vector