Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Data Visualization
  • Statistics in R
  • Machine Learning in R
  • Data Science in R
  • Packages in R
  • Data Types
  • String
  • Array
  • Vector
  • Lists
  • Matrices
  • Oops in R
Open In App
Next Article:
Replicating a Value to the Specified Length in R Programming - rep_len() Function
Next article icon

Replicating a Value specified number of times in R Programming - rep.int() Function

Last Updated : 24 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
rep.int() function in R Language is used to replicate a given value into a specified number of times.
Syntax: rep.int(x, times) Parameters: x: specified value times: specified number of times the value get printed
Example 1: Python3
# R program to illustrate # rep.int function  # Calling the rep.int() function rep.int(1:2, 2) rep.int(1:3, 1) rep.int(0:1, 4) 
Output:
  [1] 1 2 1 2  [1] 1 2 3  [1] 0 1 0 1 0 1 0 1  
Example 2: Python3
# R program to illustrate # rep.int function  # Calling the rep.int() function rep.int(c(1, 2), 2) rep.int(c(1, 2, 3), 3) rep.int(c(5), 6) 
Output:
  [1] 1 2 1 2  [1] 1 2 3 1 2 3 1 2 3  [1] 5 5 5 5 5 5  

Next Article
Replicating a Value to the Specified Length in R Programming - rep_len() Function

K

Kanchan_Ray
Improve
Article Tags :
  • R Language
  • R Vector-Function

Similar Reads

  • Replicating a Value to the Specified Length in R Programming - rep_len() Function
    rep_len() function in R Language is used to replicate a given value in the specified length. Syntax: rep_len(x, length.out) Parameters: x: specified value length.out: specified number of items get printed Example 1: # R program to illustrate # rep_len function # Calling the rep_len() function rep_le
    1 min read
  • Get a List of Numbers in the Specified Range in R Programming - seq.int() Function
    seq.int() function in R Language is used to return a list of numbers in the specified range. Syntax: seq.int(from, to, by) Parameters: from: specified range from to: specified range to by: specified number by which it jumps through returned number Example 1: # R program to illustrate # seq.int funct
    1 min read
  • Rounding off a value to specific digits in R Programming - round() Function
    R Language provides an inbuilt function round() which rounds off to the given number of digits, if no number of digits is provided for round off, it rounds off the number to the nearest integer. Syntax: round(x, digits=n) Parameter: x: Number to be rounded off digit: Specified digits Example 1: # R
    1 min read
  • Rounding up to the Specified Number of Significant Digits in R Programming - signif() Function
    signif() function in R Language is used to round to the specified number of significant digits. Syntax: signif(x, digits) Parameters: x: specified number digits: significant digits Example 1: # R program to illustrate # signif function # Generating random number x <- rnorm(1) x # Calling the sign
    1 min read
  • Search and Return an Object with the specified name in R Programming - get() Function
    get() function in R Language is used to return an object with the name specified as argument to the function. This is another method of printing values of the objects just like print function. This function can also be used to copy one object to another. Syntax: get(object) Parameters: object: Vecto
    1 min read
  • Generate Data sets of same Random Values in R Programming - set.seed() Function
    The set.seed() function in R ensures that random number generation is consistent across different sessions, allowing for identical results each time the code is executed. This is particularly important when sharing code with others or when results need to be verified. Syntax: set.seed(n) Where: n: s
    2 min read
  • Generate a Sequence from 1 to any Specified Number in R Programming - seq_len() Function
    seq_len() function in R Language is used to generate a sequence from 1 to the specified number. Syntax: seq_len(x) Parameters: x: specified number Example 1: # R program to illustrate # seq_len function # Calling the seq_len() function seq_len(1) seq_len(3) seq_len(0) seq_len(6) Output: [1] 1 [1] 1
    1 min read
  • Replace values of a Factor in R Programming - recode_factor() Function
    Factors in R programming are kind of data structures that stores categorical data i.e., levels and can have any type of data (integer, string, etc). recode_factor() function in R Language is used to replace certain values in a factor. To use recode_factor() function, dplyr package is required. Synta
    1 min read
  • Getting a Matrix of number of rows in R Programming - row() Function
    In this article, we will discuss how to find the number of rows and columns in a matrix in R Programming Language. nrow() Function in Rnrow() function in R Language is used to get the row number of a matrix. Syntax:  row(x, as.factor=FALSE) Parameters:x: matrixas.factor: a logical value indicating w
    2 min read
  • Create Repetitions of a String in R Programming - strrep() Function
    strrep() Function in R Language is used to create specified number of repetitions of a specified string. Syntax: strrep(string, n) Parameter: string: specified string n: number of repetitions Example 1: # R Program to illustrate # the use of strrep function # String to be repeated x <- "Geek
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences