So I see for a lot of objects in R there are 2 ways to create an object. For example, for a zoo
object there is zoo(....)
and as.zoo(....)
. It looks like the former is an object instantion and the latter a casting construct.
In common languages like C,Java,C# you usually use the casting operator for casting between objects within the same line of inheritance, i.e. cast child to parent classes. You would create a new object
if you have a compositional structure (many objects inside 1 object) instead of inheritance.
In R it seems I can pass a dataframe to either zoo(....)
and as.zoo(....)
and get a zoo object. So when should I use the create object
v. using as.xxx
?