Error in rep() : invalid ‘times’ argument in R (2 Examples)

This tutorial demonstrates how to avoid the “Error in rep(X) : invalid ‘times’ argument” in R.

Example 1: How to Replicate the Error in rep(X) : invalid ‘times’ argument

rep("x", - 10)                     # rep cannot be applied to negative value
# Error in rep("x", -10) : invalid 'times' argument

Example 2: How to Solve the Error in rep(X) : invalid ‘times’ argument

rep("x", 10)                       # Positive value within rep
#  [1] "x" "x" "x" "x" "x" "x" "x" "x" "x" "x"

Related Tutorials

You may find some additional R tutorials on topics such as ggplot2 and coding errors in the following list:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top