Create Vector in R Language

As we discussed about Vectors in my Previous Post, if not referred please find the below link to explore.

Vectors are the most basic R data objects and there are six types of atomic vectors. They are logical, integer, double, complex, character and raw.

Lets Take some quick examples to Create Vector :

  1. Single Vector Creation :

Even when you Just try to write one value in R, The length of vector will be 1 and belongs to one of the above vector types.

Source Pane:

Console Pane

In the source Pane we Printed Character vector, Integer Vector, Logical vector, Complex Vector and also converted Character string to raw Value .

Note :

1. Please refer my previous post to Understand the characteristics of each data types .

2. For Printing the Integer vector we printed 50L, 50 is the value to Print and L represents Integer Data Type

R Language by default stores the data of type Double, All the operations, calculations in R are conducted in Doubles because R Language anticipates all the arithmetic operations should be done with Double data type ,so it is Mandatory to mention  the L for integer Variable assignments .

3. For Printing Raw vector ,we Used Function CharToRaw to convert Character strings to Raw value(Bits/packed 8 Bit)

for ‘hello sri’ string, The converted raw value is : 68 65 6c 6c 6f 20 73 72 69

How do you Identify The converted raw Value is correct ??????? 🤔

We Have Converters available in online to Convert String values to Raw Values (Bytes/Bits)

Go to This website : Convert a String to Bytes – Online String Tools to Convert string to Raw Value

In this site, i have given the string as hello sri and it is converted to 68 65 6c 6f 20 73 72 69, R language has converted our string to the same Value.

Let’s Create Vectors with different Functions, Operators & Vector Elements in the Upcoming Posts….