3.19 Variables
20200501 We can store values, such as the resulting value from invoking a function (Section 3.6), into a variable. A variable is a name that we can use to refer to some location in the computer’s memory. Into this location we store the data while our programs are running so that we can refer to that data by the specific variable name later on. We use the assignment operator base::<- to do so:
We can access the value stored in the variable (or actually stored in
the computer’s memory that the variable name refers to) simply by
requesting through the R Console that R `run'' the commandv. We do so below with a line containing justv. In fact the R software actually runs the [base::print()](https://www.rdocumentation.org/packages/base/topics/print){ target="_blank" } function to display the contents of the computer's memory thatv` refers to—this is a convenience
that the R software provides for us.
## [1] 3
## [1] 3
By indexing the variable with [1] we can ask for the first item
referred to by v. Noting that the variable v is
a vector with only a single item when we try to index a second item we
get an NA (meaning not available or a missing value).
## [1] 3
## [1] NA
If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0