RE: [R] Using files as connections

2003-08-29 Thread maj
I nearly forgot to thank Andy Liaw and Tony Plate for their help with this problem. BTW Andy's method does run faster than the natural fix-up of my original code. Murray Jorgensen > You are using the connection the wrong way. You need to do something > like: > > fcon <- file("c:/data/perry/data

RE: [R] Using files as connections

2003-08-28 Thread Liaw, Andy
You are using the connection the wrong way. You need to do something like: fcon <- file("c:/data/perry/data.csv", open="r") for (iline in 1:slines) { isel <- isel + 1 cline <- readLines(fcon, n=1) ... } close(fcon) BTW, here's how I'd do it (not tested!): strvec <- rep("",slines) se

Re: [R] Using files as connections

2003-08-28 Thread Tony Plate
You need to save the connection object returned by file() and then use that object in other functions. You need to change the appropriate lines to the following (at least): con <- file("c:/data/perry/data.csv",open="r") cline <- readLines(con,n=1) close(con) (I don't know if more changes are n