How to use replicate() method In R Language
This function used to give n replicas from the character string
Syntax:
replicate(N, “string”)
where,
- N is the number of times string is replicated
- string is the input character string
Example: R program to repeat the character string N times using replicate
R
# get 2 times print ( replicate (2, "Hello_Geek" )) print ( "-----" ) # get 10 times print ( replicate (10, "Python" )) print ( "-----" ) # get 3 times print ( replicate (3, "java" )) print ( "-----" ) # get 4 times print ( replicate (4, "dbms" )) print ( "-----" ) # get 5 times print ( replicate (5, "sql" )) print ( "-----" ) # get 7 times print ( replicate (7, "big data" )) |
Output:
[1] “Hello_Geek” “Hello_Geek”
[1] “—–“
[1] “Python” “Python” “Python” “Python” “Python” “Python” “Python” “Python”
[9] “Python” “Python”
[1] “—–“
[1] “java” “java” “java”
[1] “—–“
[1] “dbms” “dbms” “dbms” “dbms”
[1] “—–“
[1] “sql” “sql” “sql” “sql” “sql”
[1] “—–“
[1] “big data” “big data” “big data” “big data” “big data” “big data” “big data”
Repeat Character String N Times in R
In this article, we will discuss how to repeat the character string N times in the R programming language. Character string means a set of characters .
Example:
“Hello Geek”,”Python”,”Languages_Python” are some examples
Contact Us