Weeded out all ocurences of field$data<- which should be field$data[]<-
This preserves the dimensions of the data array.
Sometimes you can get away without it, but not always.