We will look at a few important and interesting examples. You will understand the structure of vectors in R and would also be able to perform the basic arithmetic related to this requirement
Key in
letters
at the R console and hit the Enter key.To obtain the first five and the last five alphabets, try the following code:
LETTERS[c(1:5,22:26)]
andletters[c(1:5,22:26)]
.Month names and their abbreviations are available in the base package and explore them using
?Constants
at the console.Selected month names and their abbreviations can be obtained using
month.abb[c(1:3,8:10)]
andmonth.name[c(1:3,8:10)]
. Also, the value of pi in R can found by enteringpi
at the console.To generate a vector of length 4, without specifying the class, try
vector(length=4)
. In specific classes, vector objects can be generated by declaring the "mode" values for a vector object. That is,...