Maingo,
See previous discussion below on rbind.na() and cbind.na() scripts:
https://stat.ethz.ch/pipermail/r-help/2016-December/443790.html
You might consider binding first then adding orthogonally.
So rbind.na() then colSums(), OR cbind.na() then rowSums().
Best of luck,
W Michels, Ph.D.
Without recycling you would get:
u <- c(10, 20, 30)
u + 1
#[1] 11 20 30
which would be pretty inconvenient.
(Note that the recycling rule has to make a special case for when one
argument has length zero - the output then has length zero as well.)
Bill Dunlap
TIBCO Software
wdunlap
ia R-
> help
> Sent: Wednesday, December 13, 2017 6:41 AM
> To: r-help@r-project.org
> Subject: [R] Add vectors of unequal length without recycling?
>
> I'm a newbie for R lang. And I recently came across the "Recycling Rule" when
> adding two vectors of unequal len
Better get over it, because it isn't going to change. To avoid it, always work
with vectors of the same length.
This is a logical extension of the idea that a scalar adds to every element of
a vector.
--
Sent from my phone. Please excuse my brevity.
On December 12, 2017 9:41:06 PM PST,
I'm a newbie for R lang. And I recently came across the "Recycling Rule" when
adding two vectors of unequal length.
I learned from this tutor [
http://www.r-tutor.com/r-introduction/vector/vector-arithmetics ] that:
""
If two vectors are of unequal length, the shorter one will be recycled
5 matches
Mail list logo