sapply with factor data converted back to numeric, need to use lapply