[R] How to avoid "$ operator is invalid for atomic vectors"

Patrick Burns pburns at pburns.seanet.com
Thu Nov 6 20:43:59 CET 2008


cruz wrote:
> Thanks for all the responses, they are all very helpful:)
>
>   
>> you don't need to assign dimension or classes to your objects.
>> It's easier if you  do like this
>>     
>
> this is something that really bothers me, when I need to define an
> object which i will later fill with data, the dimension of this object
> should not be fixed because it will grow...
>
> so in MATLAB, i.e. we define x = [ ],
> what about in R?
>   

It is generally best in R to create an object as the size
it will end up being and then make assignments into the
object.

But using the theory of giving you enough rope to hang
yourself, you can do things like:

x <- numeric(0)

or

x <- NULL


Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

> Thanks,
> cruz
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>



More information about the R-help mailing list