R Datatypes Vectors - r - learn r - r programming



  • R had a wide range of data types like scalars, vectors, matrices, data frames, and lists.
  • A vector is the most common and basic data structure in R programming and is more attractive then others.Vectors can be of two types:
    • Atomic vectors
    • List
 r datatypes vectors

Atomic vectors:

  • The atomic vectors have six data types which is also called as six classes of vectors.
    • Logical
    • Numeric
    • Integer
    • Complex
    • Character
    • Raw

Syntax:

vector()

Sample Code:

wikitechy<- c(“R Programming”,”C Programming”,"Java")
print(wikitechy)
print(class(wikitechy))

Code Explanation:

 r datatypes vectors structure
  1. In this example, wikitechy is specifies to string variable. Here we use c(“R Programming”,”C Programming”,"Java") function which means to combine three elements into a vector.
  2. Here print() is used to print the value, that value stored in wikitechy variable.
  3. print(class(wikitechy)) specifies to class type of wikitechy.

Sample Output:

 r datatypes vectors output
  1. Here in this output we display [1] “R Programming” “C Programming” “Java” which specifies to string variable of “wikitechy”.
  2. Here we display [1] “character” which specifies to string variable wikitechy in characters data types.


Related Searches to R Datatypes Vectors