Regular Sequences Vol. 2 Exercises

(This article was first published on R-exercises, and kindly contributed to R-bloggers)

regular sequence

[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 the code:

Exercise 3

What is the output for the code:

Exercise 4

What is the output for the code:

Exercise 5

Create a sequence with values:
100 95 90 85 80 75 70 65 60 55 50

Exercise 6

What is the output for the code:

Exercise 7

What is the output for the code:

Exercise 8

What is the output for the code:

Exercise 9

Consider two variables, A and B,
A= as.Date("2016-11-01")

B = as.Date("2016-11-15")

What is the output for the code:
seq.Date(A,B, by = "1 day")

Exercise 10
Consider two variables, C and D,

C= as.Date("2016-02-01")

D = as.Date("2016-06-15")

What is the output for the code:
seq.Date(D,C, by = "-1 month")


Want to practice regular sequences a bit more? We have more exercise sets on this topic here.

Please help us to improve R-exercises:

To leave a comment for the author, please follow the link and comment on their blog: R-exercises. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)