convert R to matrix
fixed inverse error