[R] Read.fwf
Chuck Cleland
ccleland at optonline.net
Wed Sep 15 14:59:57 CEST 2004
You can use rep() in specifying the widths argument to avoid typing
all those ones. For example:
read.fwf(file="c:\\mydata.dat", widths = c(rep(1,80), 5, 4, 6))
hope this helps,
Chuck
Doran, Harold wrote:
> I have a fixed width file with variables of varying width. The help is
> pretty transparent for this feature, but I can't seem to figure out how
> I can make effective use of the package with my data.
>
> In my dataset, the first 80 columns are of width 1 followed by other
> variables with width larger than 1.
>
> I think the correct way to do this, by brute force, would be
>
>>read.fwf(dataset, 1,1,1,...,1,5,...).
>
> I'm sure I do not need to actually enter 80 "1"s, correct? How might I
> do this more effectively?
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list