R Flashcards
Rules for naming objects in R
- Names can include letters, numbers, periods (.), and underscores(_)
- They must begin with a letter or a period. If period it can’t be followed by digit.
- Reserved words like if, else, TRUE, FALSE, NA, etc., can’t be used. To find out
about reserved word in R, you can type
> ?reserved
What does the # do in R?
It is a naming method to add comments are lines in code to explain, notes, descriptions that are not executed as part of the program.
What is a function?
Functions generic syntax
function_name (argument1,…,argument = defaultt…)
What does ? do
if you need help on info about a function
Basic data types of R
Numeric data (double, integer)
String data (character)
Logical data (logical)
&
Logical operator AND
returns TRUE if both conditions are TRUE, otherwise returns FALSE.
|
Logical Operator for OR
Returns true if at least one of the conditions is TRUE, or otherwise returns FALSE.
!
NOT negates the logical value of a condition.
Precedence in logical operator
1) NOT 2) AND 3) OR
Vectors
fundamental data structure that allows you to STORE A SEQUENCE OF ELEMENTS OF THE SAME DATA TYPE.
c()
function combine to create a vector by combining elements of the same type.
Types of vectors
Numeric vectors: Contains numeric values (integers or decimals).
Character Vectors: Holds text or strings.
Logical Vectors: Consists of TRUE or FALSE values.
What happens when you compare a vector and an atomic value using operator like > < ==?
Each element within the vector is INDIVIDUALLY compared to the atomic value
length()
determine the number of elements in an object