--
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
R Tutorial
R Language Tutorial R Environment Installation R Basic Syntax R Comments R Basic Operations R Data Types R Conditional Statements R Loops R Functions R Strings R Lists R Matrices R Arrays R Factors R Data Frames R Data Reshaping R Packages R CSV Files R Excel Files R XML Files R JSON Files R MySQL Connection R Plotting - Pie Chart R Plotting - Bar Chart R Plotting - Chinese Support R Plotting - Function Curve R Plotting - Scatter Plot Operate R in Java R Language Examples
R seq() function β Generate sequence
R seq.Date() function - Generate date sequence
R seq.Date() function is used to generate equally spaced date sequences.
In time series analysis and periodic report generation, creating date sequences is a very common requirement.
The syntax of seq.Date() function is as follows:
seq(from, to, by = "days")Parameter Description:
- from Start date.
- to End date.
- by Interval: "days", "weeks", "months", "years", or "3 days", etc.
Examples
# Date Sequence of This Weekstart<-as.Date("2026-05-11")week_dates <-seq(start, by="days", length.out=7)print("Dates of This Week:")print(week_dates)
# First Day of Each Monthmonth_starts <-seq(as.Date("2026-01-01"),as.Date("2026-12-01"),by="months")print("First Day of Each Month:")print(month_starts)
Executing the above code produces the following output:
"Dates of This Week:" "2026-05-11" "2026-05-12" "2026-05-13" "2026-05-14" "2026-05-15" "2026-05-16" "2026-05-17" "First Day of Each Month:" "2026-01-01" "2026-02-01" "2026-03-01" "2026-04-01" "2026-05-01" "2026-06-01" "2026-07-01" "2026-08-01" "2026-09-01" "2026-10-01" "2026-11-01" "2026-12-01"
YouTip