Fix for as.character bug