Page 211 - Data Science class 11
P. 211
tan(x) #Tangent of x
acos(x) # arc-cosine of x
asin(x) # arc-sine of x
atan(x) #arc-tangent of x
c. Other mathematical functions
abs(x) # absolute value of x
sqrt(x) # square root of x
6.4 VariaBLes
Generally, while doing programming in any programming language, you need to use various variables to store
various types of information. Variables are nothing but reserved memory locations to store values. This means that,
when you create a variable you reserve some space in memory.
For moving the concept of variables before Script programming, the author should be consulted.
You may want to save data of various data types such as characters, wide characters, integers, floating points, double
floating points, Boolean, and so on.
Wide characters (It is a computer character datatype that generally has a size greater than the traditional 8-bit
character.
Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the
reserved memory.
6.4.1 Variable names or identifiers
A variable can have a short name (like x and y) or a more descriptive name (age, studentname, total_area).
Rules for writing variables in R are:
• A variable name must start with a letter and can be a combination of letters, digits, period(.) and underscore(_). If it
starts with a period(.), it cannot be followed by a digit.
• A variable name cannot start with a number or underscore (_)
• Variable names are case-sensitive (as a result,length, Length, LENGTH are all distinct variables).
• Reserved keywords cannot be used as variables (TRUE, FALSE, NULL, if...)
• Special characters are not allowed.
Examples of Legal variable names
1. myvar <- " Sapna"
2. my_var <- " Sapna"
3. myVar <- " Sapna"
4. MYVAR <- " Sapna"
5. myvar2 <- " Sapna"
6. .myvar <- Sapna
Examples of Illegal variable names:
1. 2myvar <- " Sapna"
Because it starts with a number.
2. my-var <- " Sapna"
Because it contains – instead of probably _.
Programming with R 209

