R has 5 basic or "atomic" data structures which are classified as objects They are as follows: character - (a-zA-Z0-9) - can be a combination of alpha-numeric combinations numeric - (decimal) - double precision real numbers integers - (basic numerical) - 0-9 complex - (complex numerical) - 1.0i logic - (boolean) - T/F - TRUE/FALSE - 0=FALSE/1+=TRUE The most basic object is a vector and has a specific rule to follow: The vector can only contain objects of like similarity ie: a vector can only have objects of like objects ie: complex objects can only contain complex vectors You can not mix two vector types inside the same object. However there is an exception to these rules and that is: List - represented as a vector but containing objects from different classes which is a sequence of objects contained inside a list and may as well that can have a list inside a previous list of different objects Empty vectors can be created with function: vector() The vector function takes 2 parameters as follows: ie: vector(numeric, length=value) ie: vector(0, length=10) If you want to have a specific numeric value to be classified a integer rather then a double precision number you must include the suffix "L". R would classify 1 as a numeric object, but 1L would be classified an integer There is also a special number Inf, of infinity or "∞" as a symbolic representation that most of the world knows Inf as. Inf can be used in ordinal calculations. ie: 1/0 = Inf ie: 1/Inf = 0 As well there is NaN that stands for Not a Number, or commonly known as an unified value, or thought of as "the missing value" ie: 0/0 = NaN Objects in R which have attributes are as follows: names, dimnames dimensions(array, matrice) class length user defined attributes and metadata Attributes of an object can be accessed through the attributes() function |

Programming and Analysis > R GNU S >