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

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (364) Python Quiz (25) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

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