[R] Using sqldf() to read in .fwf files

Gabor Grothendieck ggrothendieck at gmail.com
Mon Sep 15 21:35:13 CEST 2014

On Mon, Sep 15, 2014 at 3:23 PM, Doran, Harold <HDoran at air.org> wrote:
> Thank you, Gabor. This has seemingly resolved the issue. Perhaps a quick follow up. Suppose I know that the 1st variable I am reading in is to be numeric and the second is character. Can that be specified in the substr() argument?
> sqldf("select substr(V1, 1, 1) f1, substr(V1, 2, 4) f2 from fixed")

Cast the numeric field to real:
   select  cast(substr(V1, 1, 1) as real)  ...

More information about the R-help mailing list