My code is
ff <- tempfile()
cat(file=ff,"11220011003","11220011003",sep="\n");
x <- read.fwf(ff,widths=c(2,2,4,3))
And I get a matrix like this:
11 22 11 3
11 22 11 3
But the result I want is
11 22 0011 003
11 22 0011 003
How should I correct my code to get the matrix I want?
read.fwfreturns a data.frame, not a matrix; and it seems to be returning a data.frame of numeric vectors. If you want a data.frame of character vectors instead, specifycolClasses(see?read.table).