Page 210 - Data Science class 11
P. 210
Exercise 6.2. Exponentiation and Text Matter
Enter the following code snippet in the script panel:
R deals with text or text message data in a slightly
different way as compared to numerical data.There
are two rules here:
• All text data to be outputted should be under
double quotes "….." and then enclosed within
circular parenthesis (……..) as shown above. Then
you have to use a print statement to output the
data exactly as you enclosed.
• Observe here that in lines 3 and 4, we have given
two print statements to output a text message. The
valid print statement is print and not Print. The R
language code is always case-sensitive.
Console (Output) Panel
When a programmer uses the print statement as Print, the console displays the error statement. When print statement
is issued, it shows the message correctly.
Let us now look at one more arithmetic statement.
# Modulo: returns the remainder of the division of 8/3
8 %% 3
R Script File
Usually, you will do your programming by writing your programs in script files and then executing those scripts at
your command prompt with the help of an R interpreter called Rscript.
6.3.2 Basic arithmetic Functions
Functions: The functions which are already created or defined in the programming framework are known as built-in
functions. R has a rich set of functions that can be used to perform almost every task for the user.
a. Logarithms and Exponentials:
log (x) # logarithms base 2 of x
2
log (x) # logaritms base 10 of x
10
exp(x) # Exponential of x
b. Trigonometric functions:
cos(x) # Cosine of x
sin(x) # Sine of x
208 Touchpad Data Science-XI

