You missed the each=
argument to rep()
:
R> n <- 3
R> rep(1:5, each=n)
[1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5
R>
so your example can be done with a simple
R> rep(1:8, each=20)
More Related Contents:
- Repeat each row of data.frame the number of times specified in a column
- Repeat rows of a data.frame [duplicate]
- Generate a repeating sequence based on vector
- Select every other element from a vector
- Generate an incrementally increasing sequence like 112123123412345
- How to Loop/Repeat a Linear Regression in R
- Repeat vector when its length is not a multiple of desired total length
- Extract rows based on only one column using R [closed]
- ggplot with 2 y axes on each side and different scales
- Counting unique / distinct values by group in a data frame
- cbind a dataframe with an empty dataframe – cbind.fill?
- Plot a legend outside of the plotting area in base graphics?
- Concatenate a vector of strings/character
- Split text string in a data.table columns
- Collapsing data frame by selecting one row per group
- R command for setting working directory to source file location in Rstudio
- ggplot2 pie and donut chart on same plot
- R help page as object
- Install Rtools on R version 3.0.2
- how to change the color in geom_point or lines in ggplot [duplicate]
- Convert a character vector of mixed numbers, fractions, and integers to numeric
- Options for caching / memoization / hashing in R
- R – when trying to install package: InternetOpenUrl failed
- R – Markdown avoiding package loading messages
- Simplified dput() in R
- How to append a whole dataframe to a CSV in R
- How to increase the size of points in legend of ggplot2? [duplicate]
- Creating a named list from two vectors (names, values)
- R: How to split a data frame into training, validation, and test sets?
- Match legend text color in geom_text to symbol [duplicate]