[R] Scanning data lines with blanks in character vars

s-luppescu@uchicago.edu s-luppescu at uchicago.edu
Thu May 10 23:45:05 CEST 2001

Hello, I'm trying to read data in from a file using scan(). The last field is a
character string that contains blanks. I had read it in in S-Plus using this

ifile <- list(entry=0,measure=0,st=0,count=0,score=0,
if.widths <- c(1, 5, 8, 3, 6, 7, 7, 7, 7, 7, 7, 7, 7, 2, 2, 85)
d1 <- scan(file=fd,ifile,flush=T,skip=0,widths=if.widths)

The name variable is a character string that contains blanks, is of varying
length (maximum length is 85), varying number of words and is not surrounded by
quotes. It always starts at position 84 on the line and goes to the end of the

This used to work in S-Plus 3.4 in SunOS (but it seems not to anymore, since we
moved to version 5 -- but that's besides the point). Anyway, since there is no
widths= in scan() in R, how do I read in a string containing blanks?
Stuart Luppescu         -=-=-  University of Chicago
$(B:MJ8$HCRF`H~$NIc(B        -=-=-  s-luppescu at uchicago.edu
http://musuko.uchicago.edu/pubkey.asc for PGP Public Key
ICQ #21172047  AIM: psycho7070
Eat shit -- billions of flies can't be wrong.
>> Sent on 10-May-2001 at 15:08:04 with xfmail
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list