You need to understand that typeof returns a rather low level characteristic and that is( ... , "language") checks for a slightly higher level of abstraction. typeof little use. It is usually more useful to query the class of an object:
> class(parsed) [1] "expression" > class(parsed[[1]]) [1] "="
This second one may seem a little strange, and I would think that it is the result of eitehr a call or or Ops , but if you look at:
parsed[[1]]
You see that the call object represents internally, that is, a parsing tree, like:
`=`( cylinders, c(4, 6, 8) )
... noting that:
parsed[[1]][[1]] `=` # note the backticks signifying a function, a language object
... and that this is really an object call:
is.call( parsed[[1]] ) #[1] TRUE
See ?parse Parse for a description of the function returning an invaluable call object. I'm more of an S3 guy, so I'm trying to explain what happens to your S4 stuff above my pay level. Please note that the error message from your unsuccessful S4 attempts referred to a "class" mismatch, not a "typeof"
source share