Wednesday, 8 August 2018

Data Management : Lists in R Language

Vectors, matrices, and arrays is that each of these types of objects may only contain one type of data.

For example, a vector may contain all numeric data or all character data.

A list is a special type of object that can contain data of multiple types.

Lists are characterized by the fact that their element do not need to be of the same object type.

Lists can contain elements of different types so that the list elements may have different modes.

Lists can even contain other structured objects, such as lists and data frames which allows to create recursive data structures.

Lists can be indexed by position.
  So x [ [5] ] refers to the fifth element of x.

Lists can extract sublists.
 - So x [c (2,5) ] is a sublists of x that consists of the second and fifth elements.

Lists elements can have names.
 - Both x [ ["Students"] ] and x$Students refer to the element named "Students".

Difference between a vector and a list :
  • In a vector, all element must have the same mode.
  • In a list, the elements can have different modes.

Modes :

Every objects has a mode.

The mode indicates how the object is stored in memory: as a 
  1. number
  2. character string 
  3. list of pointers to other objects,
  4. function etc.


Mode function give us such information.

Syntax

mode ( )

Example

> mode (1.234)
 [1]  "numeric"

> mode ( c(5,6,7,8) )
  [1]  "numeric"

> mode ("India")
  [1]  "character"

> mode ( c( "India" , "USA") )
  [1]  "character"

  
Example

> mode (factor (c ("UP" , "MP") )   )
  [1]  "numeric "

> mode (list ("India", "USA") )
 [1]  "list"

>mode (data.frame (x=1:2, Y=c ("India", "USA" ) ) )
  [1]   "list"

> mode (print)
  [1]  "function"


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