R not reading properly data structure incorrect