sandoval31 sandoval31 - 1 month ago 7
R Question

How to declare a vector of zeros in R

I suppose this is trivial, but I can't find how to declare a vector of zeros in R.

For example, in Matlab, I would write:

X = zeros(1,3);

Answer

You have several options

integer(3)
numeric(3)
rep(0, 3)
rep(0L, 3)