So far in this series, we used vectors from built-in datasets (rivers, women and nhtemp), or created them by stringing together several numbers with the c function (e.g. c(1, 2, 3, 4)). R offers an extremely useful shortcut to create vectors of the latter kind, which is the colon : operator. Instead of having to […]
regular sequences
Regular Sequences Vol. 2 Exercises
[For this exercise, first write down your answer, without using R. Then, check your answer using R.] Answers to the exercises are available here. Exercise 1 if x <- c(a = 1, b = 2,c=3,d=4) What is the output for the code: seq(5,11,along.with =x) Exercise 2 If x= seq(4,12,4) , what is the output for […]
Regular sequences
Before proceeding, please review Chapter 2 of An Introduction to R and the internal R Documentation for the seq() function (type ?seq in the R console). Solutions are available here. Excercise 1 Using the seq() function, generate the sequence 2, 5, 8, 11. Exercise 2 Use the seq() function to generate the sequence 9, […]