Replace use of as.real (which is deprecated) with as.double