Use sequence
:
> sequence(1:5)
[1] 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
More Related Contents:
- Fixing the order of facets in ggplot
- Create grouping variable for consecutive sequences and split vector
- Create counter within consecutive runs of values
- Create a group number for each consecutive sequence
- Create sequence of repeated values, in sequence?
- generate sequence within group in R [duplicate]
- rep() with each equals a vector
- Create integer sequences defined by ‘from’ and ‘to’ vectors
- Select every other element from a vector
- Insert blanks into a vector for, e.g., minor tick labels in R
- Repeat vector when its length is not a multiple of desired total length
- Create counter of consecutive runs of a certain value
- Creating a unique sequence of dates
- Deleting every n-th row in a dataframe
- Create a Vector of All Days Between Two Dates
- Sum by two variables
- Use dynamic name for new column/variable in `dplyr`
- geom_rect and alpha – does this work with hard coded values?
- Fill in missing values by group in data.table
- Label and color leaf dendrogram
- Similarity scores based on string comparison in R (edit distance)
- How do I show the y value on tooltip while hover in ggplot2
- Use filter in dplyr conditional on an if statement in R
- Finding the index inside a vector satisfying a condition
- finding close match from data frame 1 in data fame 2
- Showing string in formula and not as variable in lm fit
- select columns based on multiple strings with dplyr contains()
- Calculate number of days between two dates in r
- How to get geom_vline to honor facet_wrap?
- Data.frame Merge and Selection of values which are common in 2 Data.frames