R for Data Analytics MCQ - R Programming Fundamentals
R Programming Fundamentals – Quick Revision Notes
score, Score, and SCORE
are treated as different names.# symbol.
Comments are ignored when the code is executed.<-. The =
operator can also perform assignment in many contexts, although
<- is conventionally used in R code.class() to determine the class of an R
object and typeof() to inspect its underlying type.print() explicitly displays an object in the
console. cat() is useful for combining and
displaying text and values in a more compact form.ls() lists objects in an environment, while
rm() removes specified objects.getwd() returns the current working directory.
setwd() changes the working directory.source() reads and executes R commands stored
in a script file.+,
-,
*,
/, and
^.
The ^ operator performs exponentiation.%% returns the remainder of a division, while
%/% performs integer division.==,
!=,
>,
<,
>=, and
<=.& for AND,
| for OR, and
! for NOT.&& and
|| are short-circuit logical operators,
generally used when evaluating a single condition.%in% checks whether values occur in another
set of values.if,
else if, and
else.switch() can be useful when one of several
alternatives needs to be selected from a single expression.for loop is commonly used to iterate through
a known sequence.while loop continues as long as its condition
evaluates to TRUE.repeat loop continues indefinitely unless it
is explicitly terminated.break immediately exits a loop, while
next skips the remainder of the current
iteration and continues with the next one.function keyword.return() can explicitly return a value from a
function. If it is omitted, R normally returns the value of the function\\\'s
last evaluated expression.install.packages() installs a package, while
library() loads an installed package for use.attach() can make components of an object
directly accessible by name, while detach()
removes an attached object from the search path.help() opens documentation for a topic.
The ? operator provides a shorthand, such as
?print.help.search() searches the R documentation
when the exact help-topic name is unknown.args() displays the formal arguments of a
function.NaN means Not a Number and
represents an undefined numeric result, such as 0/0.Inf and -Inf
represent positive and negative infinity respectively.abs() returns the absolute value of a number.Remember These Common Distinctions
= / <- → assignment,
whereas == → comparison./ → ordinary division,
%/% → integer division,
%% → remainder.& → logical AND,
| → logical OR,
! → logical NOT.break → leave the loop;
next → skip only the current iteration.install.packages() → install a package;
library() → load it.getwd() → get the working directory;
setwd() → change it.print() → standard object output;
cat() → convenient text/value output.help() → open known documentation;
help.search() → search documentation.NaN → undefined numeric result;
Inf → infinity.

