r-lib / rray

Simple Arrays
https://rray.r-lib.org
GNU General Public License v3.0
130 stars 12 forks source link

A comment about broadcasting vignette #216

Closed juangomezduaso closed 5 years ago

juangomezduaso commented 5 years ago

In line 40 says: "In one sentence, the answer is that R recycles, but I want it to broadcast." We have a 2x2 crossing here (broadcast , recycle) x (along pos, along axes) and I think this sentence could perhaps be improved somehow to clarify things. I am bad counselor about documentation but here are some ideas: As it is explained in vctrs, recycling vectors is too much. Broadcasting is the most useful and meaningful behavior. The situation with base arrays is that R doesnt recycle along dimensions, only on the bare vector. So it does too much and too little at a time. What is needed for arrays is just to have broadcasting, but to have it along the dimensions

DavisVaughan commented 5 years ago

The real confusion is that R recycles (+ partial recycles) 1D vectors as you say, but does nothing with "recycling" matrices/arrays.

As laid out in the rules a bit later, broadcasting in rray is essentially:

So unfortunately the ideas of R recycling and tidyverse recycling are all mentioned together, in different contexts

juangomezduaso commented 5 years ago

Oh you are right. The term used in vctrs is also "recycle", not "broadcast".

DavisVaughan commented 5 years ago

Personally I think those docs are fairly clear, but then again I wrote them. Do you have any suggestions to make them better, or did what I say resolve your original question?

juangomezduaso commented 5 years ago

Well, I am neither the best person to judge it, as I am too much inmerse in these concepts ;) I thought that the introduction in line 40 could be improved, avoiding the names and going straight to the need to broadcast along all axes. But after trying to do it myself, I think that it is not so easy. You stablish the name and gradually through the examples and the rules the concept will become clear when you read it all as it is now. So i will close this issue (at least until some inspiration allows me to contribute in any way).

DavisVaughan commented 5 years ago

Yea I think "broadcast along all axes" is the wrong terminology. I think more correct is that broadcasting is sort of like "the act of tidyverse recycling along each axis", plus the nuance that you have to add the implicit dimensionality as needed