[R] Selective column loads with scan()
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Jan 8 00:00:55 CET 2001
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
> > Try
> >
> > scan(file.name, what = list(, , ""), flush = TRUE)
[ really: scan(file.name, what = list(NULL, NULL, ""), flush = TRUE)
> Unfortunately that gives you the first column. With S you need the NULLs
> in there (and then it is a known trick), but they are not accepted in R.
...>
> I don't know a good way to do this in R, but then I would not try it.
> Either use `cut' to extract the columns(s) needed from the file, or
> use a database and a connection such as RODBC to do the extraction in the
> database.
Doesn't look like rocket science to make the NULL entries work in R,
but probably a tad late for 1.2.1 (next Monday)
Basically, I think it would amount to (in src/main/scan.c):
* The allocation code in scanFrame should stick in a NULL for ans[i]
rather than error out if what[i] is NULL. Also watch for this when
the n == blksize && colsread == 0 condition is handled.
* fillBuffer should treat NULL as STRSXP
* extractItem should ignore NULL types (does already, it seems)
On the other hand, it might make better sense to have a mask= argument
controlling which columns that are kept/discarded. Or select=.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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