[R] list to data frame by rows ...
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri May 18 19:14:14 CEST 2001
Johann Petrak <johann at ai.univie.ac.at> writes:
> What is the best way to learn about how things are done internally in R?
> I didnt come across this anywhere in the documentation, but
> maybe I overlooked it.
> It would be nice to have something like "R for programmers"
> that elaborates a bit on the internal data structures,
> and the kind and efficiency of (basic) operations on them.
> Like, every LISP programmer knows which operations on lists
> will be fast and which slow, and how e.g. make appending
> to the end of a list fast, when do shallow or deep copies
> occur, what will cause GC and what avoids it.
That's to some extent what the R language reference tries to do, but
for many topics, the actual text needs to be written. (As you know,
there are two problems with documentation: (a) getting people to write
it (b) getting people to read it). Of course the ultimate answer is
the source code...
R doesn't really have lists in the LISP sense, except in its
internals. They are really generic vectors and thus have a fixed
length (so extending them requires a copy). There's the occasional
object of mode "pairlist" visible in R; these are LISP-like, but you
can't really do anything with them.
> So just as a basic question here: will all assignments of big
> datastructures always do a deep copy?
There's no concept of references, so in that sense, yes (.Alias()
notwithstanding). However, R does try to be smart about intermediate
results by keeping track of whether and object is named and not
duplicating if it is not.
Assignment to a part of a structure will not (usually) cause
duplication, unless the size is changed.
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