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:
Getting and Setting Length of the Vectors in R Programming - length() Function
Next article icon

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

Last Updated : 24 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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: Python3
# R program to illustrate # rep_len function  # Calling the rep_len() function rep_len(1:5, 5) rep_len(1:5, 7) rep_len(1:5, 10) 
Output:
  [1] 1 2 3 4 5  [1] 1 2 3 4 5 1 2  [1] 1 2 3 4 5 1 2 3 4 5  
Example 2: Python3
# R program to illustrate # rep_len function  # Calling the rep_len() function rep_len(c(1, 2), 4) rep_len(c(1, 2, 3), 5) rep_len(c(5), 6) 
Output:
  [1] 1 2 1 2  [1] 1 2 3 1 2  [1] 5 5 5 5 5 5  

Next Article
Getting and Setting Length of the Vectors in R Programming - length() Function

K

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

Similar Reads

  • Replicating a Value specified number of times in R Programming - rep.int() Function
    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: # R program to illustrate # rep.int function # Calling the rep.int() functi
    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
  • Getting and Setting Length of the Vectors in R Programming - length() Function
    In R, the length() function is used to determine the number of elements in a vector. Vectors can be of various types, such as numeric, character, or logical, and the length() function provides a simple way to find out how many elements are contained in a vector. This function is versatile and can al
    5 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
  • 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
  • Print the Argument to the Screen in R Programming - print() Function
    print() function in R Language is used to print out the argument to the screen. Syntax: print(x, digits, na.print) Parameters: x: specified argument to be displayed digits: defines minimal number of significant digits na.print: indicates NA values output format Example 1: # R program to illustrate #
    1 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
  • 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
  • Replicate elements of vector in R programming - rep() Method
    In the R programming language, A very useful function for creating a vector by repeating a given numbervector with the specified number of times is the rep(). The general structure of rep() : rep(v1,n1). Here, v1 is repeated n1 times. R - replicate elements of vector The forms of rep() functions : r
    1 min read
  • Convert a UTF8 value to Integer in R Programming - utf8ToInt() Function
    utf8ToInt() function in R Language is used to convert a UTF8 value to an integer value. Syntax: utf8ToInt(x, multiple) Parameters: x: Integer or integer vector multiple: Boolean value to convert into single or multiple strings Example 1: # R program to convert a UTF8 to Integer # Calling the utf8ToI
    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