[R-SIG-Mac] How to add variables to a vector
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Sat Mar 28 21:25:55 CET 2020
On 28/03/2020 4:17 p.m., David wrote:
> If I have a vector created like x <- c(5,1,9,3), how can I add values to
> it later? That seems simple, but I don't find the answer in either of
> my Dalgaard or Crawley books, or in the help functions. Thanks.
This question belongs on R-help: nothing to do with MacOS. But the
answer is to use c(), or just assign to a nonexistent location. For
example,
x <- c(5,1,9,3)
x <- c(x, 10)
x[10] <- 20
This will result in x printing as
[1] 5 1 9 3 10 NA NA NA NA 20
More information about the R-SIG-Mac
mailing list