Page 201 - Data Science class 11
P. 201

To do simple calculations, add numbers together:

            Example

            5 + 758
            Enter the following code snippet in the script pane, then select it and press Run from the pane:

                5
                10.33
                758
                "Hello India!"
                5 + 758
            After running the code snippet, see the console panel, which may look like below:

























            6.1.1 output in r language

            Simply enter the variable name or expression at the command prompt, R will print its value. Use the print function for
            generic printing of any object. Use the cat function for producing custom formatted output.
            The simple printing method in R is to use print(). As its name indicates, this method prints its arguments on the R
            console. However, cat() does the same thing but is valid only for Atomic types (Definition-Primitive or basic data types
            are known as atomic types) and names. Use the R-commands cat() or print() to display (or print) a text. Note that in
            each case, the text is considered by R as a script, so it should be in quotes.

            cat is useful for producing output in user-defined functions. It converts its arguments to character vectors, concatenates
            them to a single character vector,


            6.2 Basic Data tyPes

            Basic data types in R can be divided into the following types:
               • numeric—(12.5, 345, 787)
               • integer—(1L, 55L, 100L, where the letter "L" declares this as an integer)

               • complex—(8 + 3i, where "i" is the imaginary part). Complex numbers are used in vector calculus.
               • character (a.k.a. string)—("k", "R is marvelous", "FALSE", "11.5")

               • logical (a.k.a. boolean)—(TRUE or FALSE)




                                                                                         Programming with R    199
   196   197   198   199   200   201   202   203   204   205   206