EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials R Programming Tutorial R Vectors
 

R Vectors

Priya Pedamkar
Article byPriya Pedamkar

Updated March 21, 2023

R Vectors

 

 

Introduction to R Vectors

R vectors are the simplest form of data structure that holds elements of primitive data types. R language supports a built-in function c() to create the vector-type variables and assign values to them. Also, there is ‘ : ‘ the operator is used to create and define the vector variable. To access the elements from the vector variable, the R language uses the index position, which starts with index 1 for the first element of the vector variable. These are highly used by the R programmer for storing and processing data. R language supports modifying and removing an element from the vector variables.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Single Element Vectors

The data created with one value is of the vector of length 1.

  • character

Example: print(“xyz”)

  • Integer

Example: print(54L)

  • Double

Example: print(6.5)

  • Complex

Example: print(45L)

  • logical

Example: print(FALSE)

  • Raw

Example: print(1+3i)

Multiple Element Vector

We can also create a vector with multiple values using the colon with numerical data.

Example:

v <- 5:10
print(v)

Output: 5  6  7  8  9 10

The sequence of decimal values.

v <- 6.6:9.6
print(v)

Output: 6.6  7.6  8.6  9.6

In the below example,11.4 will not be in the sequence, and it will be discarded as it doesn’t belong in the sequence.

v <- 3.8:8.4
print(v)

Output: 3.8  4.8  5.8  6.8  7.8

Recommended Articles

This is a guide to R Vectors. Here we discuss the different types of vector functions with syntax and examples respectively. You may also have a look at the following articles to learn more –

  1. Functions in R
  2. GLM in R
  3. R String Functions
  4. C# Functions
Primary Sidebar
Footer
Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW