3

I'm using colsplit to split a large string to columns.
there are numbers in the string with leading zeros.
How can I prevent colsplit from converting them to numeric values?

Example:
value in string: 0000122517
after colsplit this becomes: 122517

I need the leading zeros, and the values can be of any length, so I
cannot add the zeros afterwards.

Kind regards, Oene Douma

Oene Douma
  • 33
  • 2

1 Answers1

1

We can use read.table

read.table(text=str, sep="~", header=FALSE, colClasses = c("character", "character"))
akrun
  • 874,273
  • 37
  • 540
  • 662