Skip to content
Prev 164486 / 398503 Next

R imperfections? -- was: repeated searching of no-missing values

replies inline below.
Bert Gunter wrote:
do you have any idea how much old code has been broken in the history of
programming just because programming languages moved from version x to
version x+1?  the argument that old code would be broken is repeated
here ad nauseam, literally.  there always is a tradeoff between
protecting the old developers against the need for reimplementation of
existing code and protecting the future developers against the need to
spend days on figuring our how to hack around broken designs and
implementations.
packages play an important role in about every language.  but packages,
especially ones written by third parties, should serve as an *extension*
of the core functionality, and not as a replacement.  perhaps it is just
fine to say that a function from plyr should be used instead of tapply
(which, note, is in the base package).  but perhaps the core stuff
should rather evolve than be duplicated by external patches.

as to the original problem, since you (bert) say:

"?tapply says that the first argument is an **atomic** vector. A factor
is not an atomic vector. So tapply interprets it as such by looking only
at its representation, which is as integer values."

can you explain the following:

is.atomic(as.factor(1:10))
# TRUE

is.atomic(factor(0))
# TRUE

?is.atomic says:

"'is.atomic' returns 'TRUE' if 'x' is an atomic vector (or 'NULL') and
'FALSE' otherwise."

which seems incoherent with the above, and also with the following:

f = factor(0)
is.atomic(f)
# TRUE
is.vector(f)
# FALSE

?vector says:

"Note that factors are _not_ vectors;  'is.vector' returns 'FALSE'"

if f is not a vector, how can it be an atomic vector?  perhaps
'is.atomic' does not mean what i would naively assume reading the docs; 
with r, one has to learn not to use common sense, as in, e.g., the case
of sort.list.
given how comments such as those of stavros or mine are typically
answered, indeed one cannot expect much more.  the question is, why
would one not want to ask for more?
again, same send-a-patch talk.  can't you possibly dissect between
design and implementation?  should every conceptual discussion be
replaced by a flow of patches?  python's peps have already been
mentioned;  another counterexample is jcp.  i agree that contributing
code is desirable, but discarding any other initiative  right away is
plainly rude, even if not verbally.
radio erewan strikes again?  what is so 'of course'?  stavros is right
here, and he is also right in that learning r is not quite as easy as
you seem to imply.  sure, one learns the basics in a minute, but then
it's like a ride with broken brakes.
could you actually explain this bit: "There are just too many possible
data structures to expect logical consistency in their handling
throughout... "?  everyone can see that data structures are not handled
particularly consistently in r, but why would this be a must in a modern
programming language?

vQ