Page 242 - Data Science class 11
P. 242

# Extracting first two rows.
             result <- emp.data[1:2,]
             print(result)
        On execution of the above code, the following result is shown:


















                Recap


           Ÿ  Variables are used to store the data, Comments are used to improve code readability, and Keywords are reserved words
           that hold a specific meaning to the compiler.
           Basic data types in R can be divided into the following types: numeric, integer, complex, character (a.k.a. string) and logical
           Ÿ
           (a.k.a. boolean).
           A numeric data type is the most common type in R, and contains any number with or without a decimal.
           Ÿ
           Integers are numeric data without decimals.
           Ÿ
           A complex number is the sum of a real number and an imaginary number.
           Ÿ
           Raw data, also known as primary data, are data (e.g., numbers, instrument readings, figures, etc.) collected from a source.
           Ÿ
           Ÿ  The basic arithmetic operators are: + (addition), - (subtraction), * (multiplication), / (division), ^ (exponentiation) and %%
           Modulus.
           The command statement is always shown in blue and remarks in green but followed by #.
           Ÿ
           A script lets you control the program that you created with coding.
           Ÿ
           Variables are nothing but reserved memory locations to store values.
           Ÿ
           The variables can be assigned values using the leftward, rightward, and equal to operators.
           Ÿ
           In R, a sequence of elements that share the same data type is known as a vector.
           Ÿ
           Ÿ  There are two types of vectors: Atomic vectors and Lists.
           Integer and double vectors are collectively known as numeric vectors.
           Ÿ
           Lists are sometimes called recursive vectors because lists can contain other lists.
           Ÿ
           When a person writes just one value in R, it becomes a vector of length one and is called a single-element vector.
           Ÿ
           When a person writes more than one value in R, it is called a multiple-element vector. We can create a multiple-element
           Ÿ
           vector with numeric data using the colon operator.
           The return type is determined by the highest type of the components in the hierarchy expression: > list > character >
           Ÿ
           complex > double > integer > logical > raw > NULL.
           Ÿ  A list in R is a type of R object that contains different types of elements like—numbers, vectors, strings, and another list
           within it.
           Matrices are the R objects in which the elements are arranged in a two-dimensional rectangular layout.
           Ÿ
           Arrays are the R data objects in which we can store data in more than two dimensions.
           Ÿ
           A data frame is a table or a two-dimensional array-like structure in which each column contains values of one variable and
           Ÿ
           each row contains one set of values from each column.




          240   Touchpad Data Science-XI
   237   238   239   240   241   242   243   244   245   246   247