convert data.frame character vars to factor