How to stop coercing text to numeric for specific column

234 Views Asked by At

I have xsl sheet with 21 columns, one column contains postal code which should be a factor rather than numeric but before I can convert it into a factor the read_xsl function is coercing the Postal codes like 05408 to 5408 as a numeric how can I stop this from happening or change back the codes with 0**** to their original form.

I tried read_xsl(data, coltypes = 'text') but all the columns are converted to text so how can I stop this from happening? (Dataframe is too big to be provided)

1

There are 1 best solutions below

0
JoMa On

Instead of coltypes = 'text' use col_types = c('text', ...) and define the type of every column inside the vector.