info201 / book

Source code for the course book
Other
21 stars 35 forks source link

named vectors and indexing by name #17

Closed otoomet closed 7 years ago

otoomet commented 7 years ago

The statement in 8.1 (Lists) "Elements in a list can be tagged with with names..." is correct but it also applies to vectors. You can create named vectors in exactly the same way a <- c(a=1, b=2) (obviously, data type restrictions still apply). So it is misleading to say that names is a main difference b/w vectors and lists. Also, lists are considered vectors, see ?vector and is.vector.

Maybe should talk about vector names and indexing by names separately? Note that indexing by name works in more-or-less same way for vectors, lists, and factors. To confuse the users more, the first two are considered vectors but factors are not...

mkfreeman commented 7 years ago

Thanks for catching this @otoomet -- I had noted it briefly and knew it needed updating. I think this is an instance when we'll need to talk about convention / usefulness (named vectors are rare and rarely helpful) in addition to formal definitions. Happy to revise as I work through the book.

otoomet commented 7 years ago

Sure. Let's chat next week!