Friday 10 August 2018

Data Management : Vector indexing in R Language

A vector of positive integers (letters, and Letters return the 26 lowercase and uppercase letters, respectively).

> letters [1 : 3]
 [1] "a"  "b"  "c"

> letters [c(2,4,6) ]
 [1]  "b"  "d"  "f'"

> LETTERS [1 : 3]
  [1]  "A"  "B"  "C"

> LETTERS [ c(2,4,6) ]
  [1]  "B"  "D"  "E"

> letters
 [1]  "a"  "b"  "c"  "d"  "e"  "f"  "g"  "h"  "i"  "j"  "k"  "l"  "m"  
[14] "n"  "o"  "p"  "q"  "r"  "s"  "t"  "u"  "v" "w"  "x"  "y"  "z" 
>
> LETTERS
 [1]  "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"  "K"  "L"  "M"
[14]  "N"  "O"  "P"  "Q"  "R"  "S"  "T"  "U"  "V"  "W"  "X"  "Y"  "Z"
>
> letters [1] 
 [1]  "a" 
>
> letters [14]
 [1]  "n"
>  Letters [1]
  [1]  "A"
> LETTERS [14]
 [1]  "N"
> letters [c(12,20,26) ]
 [1]  "1"  "t"  "z"


String vector
→ The elements of a vector can be named.
      Using these names, we can access the vector elements.

names is used for functions to get or set the names of an object.
> z <- list (al = 1, a2 = "c" , a3 = 1 :3)
> z
$al
 [1]  1
$a2
 [1]  "c"
$a3
 [1] 1 2 3

> names (z)
[1]  "a1"  "a2"  "a3"

Matrices created from Lists

List can be heterogeneous (mixed modes).
We can start with a heterogeneous list, give it dimensions, and thus create a heterogeneous matrix that is a mixture of numeric and character data:
Example
> ab  <- list (1, 2, 3, "x", "y" , "z")
> dim(ab)  <- c(2,3)
> print(ab)
      [,1]  [,2]  [,3]
[1,]   1     3      "y"
[2,]   2    "x"    "z"




0 Comments:

Post a Comment

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (112) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (85) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (18) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (43) Meta (18) MICHIGAN (4) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (719) Python Coding Challenge (155) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses