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

Jeffrey Horner jeff.horner at vanderbilt.edu
Thu Nov 6 19:28:29 CET 2008


cruz wrote on 11/06/2008 12:16 PM:
> 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?

?numeric, ?character, others probably...

x <- numeric()

x[10] <- 42
print(x)
  [1] NA NA NA NA NA NA NA NA NA 42

Does that answer your question?

Jeff

> 
> 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.


-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner



More information about the R-help mailing list