Python has the type
function which tells you if something is a list, numpy array or a string etc. That is, it tells you the class of the object. However, R seems to have just typeof
and class
functions that tell you what the internal data type is - say, it gives double
when I do typeof(array(1,2))
, and it gives list when I do typeof(list(1,'a'))
. My questions are:
- What exactly do typeof and class do? Why don't I get array and list above, or integer and integer/character? Moreover, where do these two methods differ?
- What if I want to know what the type of object at hand is - i.e. is it a list? A matrix? An array (in the case above)? A string? Is there a way to do this other than doing something like referring to each specific one in a way such as
is.array
(not sure if that's a thing even)?