What's new

# YouTubeR Programming: Introduction (Atomic Vectors) (R Intro-01)

#### Nicole Seaman

##### Chief Admin Officer
Staff member
Subscriber
Vectors are natural to R. David starts by creating a numeric vector with the command: three_dice ＜- c(2, 3, 6). He forgot to mention in the video that "c" here stands for "combine," as in we are "combining these three values as elements in a new vector called three_dice." We can think of this as a column vector that contains (ie, has a length of) three elements. The command, one_die ＜- 4, creates a vector of length equal to one; this is called a scalar. So even individual values are stored as vectors. Vectors are either ATOMIC or LISTS. In an ATOMIC vector, all of the elements are of the same TYPE, either: logical, integer, double, or character. When you create an atomic vector, R will "coerce" elements to match, from the least (logical) to most flexible (character). A LIST (in contrast to an atomic vector) can hold elements of different TYPES, including a list element can be another list! A data frame is a list of equal-length vectors such that it has a rectangular shape (and is the most common data structure. But this video only introduces Atomic Vectors, not lists/data frames)

David's script for this can be found at https://github.com/bionicturtle/youtube/tree/master/r-intro Last edited: