Skip to content
Prev 279392 / 398503 Next

lists everywhere

First, some general suggestions:
  To see the structure of an object I would recommend
  the str() function or, for a more concise output,
  the class() function.

  I don't think most ordinary users should be using
  is.list() and, especially, is.vector().

Now for the particulars.
  dbGetQuery probably returns an object of class "data.frame".
  data.frames are implemented as lists with certain attributes,
  so if 'dat' is a data.frame then is.list(dat) reports TRUE.
  class(dat) would report "data.frame", which is what you want
  to know.  Similarly, dat[1] is a data.frame so is.list(dat[1])
  reports TRUE.  dat[[1]] is a column of a data.frame, not a
  data.frame, and class(dat[[1]]) will tell you its class.

  I haven't come across a case where is.vector is useful.
  is.vector(x) returns TRUE if x has no attributes other than "names"
  is x is not a language object, environment, or other esoteric
  type.  E.g., is.vector of a factor object returns FALSE and
  is.vector of a numeric object or a list object returns TRUE
  (unless the object has some attributes).
  is.vector has nothing to do with the concept of a vector in linear
  algebra (or aviation or physics or almost anywhere else).

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com