R Programming Flashcards
A popular programming language used for statistical computing and graphical presentation
its most common use is to analyze and visualize data
R
R is case sensitive
True
R execution command
Ctrl a + alt enter to run/
Select + alt enter to run
How to input string?
inside double quotation marks
How to input numbers?
As is
There is a multiline comment in R
False
use ________________ for single line comment
#
containers for storing data values
Variable
R does not have a command for declaring a variable
True
You do not have to use a function to output or print
True
is created the moment you first assign a value to it
Variable
How to assign a variable?
use <- assignment operator
How to out to input or print the variable value?
Just type the variable name or use use print()function
variable name
Name <- “John”
Age <- 40
Name
Age
use print()
Name <- “John”
Age <- 40
print(Name)
print(Age)
You can also ________________, or join two or more elements using the paste() function
Concatenate
R allows you to assign the same value in multiple variables in one line
True
You CAN use any variable name in R ptogramming
False
There only legal variables to use in R
myvar <- “John”
my_var <- “John”
myVar <- “John”
MYVAR <- “John”
myvar2 <- “John”
myvar <- John
Legal Variable Names
Variable should not start with number
True
No other symbols other than underscore in a variable name
True
There should be no white spaces in a variable name
True
Variable name should not start with underscores
True
no other symbols other than underscore
True
2myvar <- “John”
should not start with number
my-var <- “John”
no other symbols other than underscore
my var <- “John”
no white spaces
_my_var <- “John”
should not start with underscores
my_v@ar <- “John”
no other symbols other than underscore
TRUE <- “John”
do not use a reserved code, in this case it is Boolean
Illegal Variable Names
We can use the ____________function to check the data type
class()
number followed by L
Integer
Numeric data without decimals
Integer
Used when you are certain that you will never create a variable that could contain a decimal
Integer
A ____________ number is written with an “i” as the imaginary part
Complex
You can convert from one type to another
True
You can convert from one type to another with the following functions:
as.numeric()
as.integer()
as.complex()
There are three basic constructs to consider:
Iteration - repeated until condition is met
Sequence - top to bottom
Selection or conditional - selected conditionally
Three condition statements
if statement
Else if statement
If else statement
R also has many ____________ functions that allows you to perform mathematical tasks on numbers
Built-in Math Functions
____________ and ____________ functions can be used to find the lowest or highest number in a set
the min() and max()
Built-in Math Functions that gets the square root of a number
sqrt()
gets the non-negative value of the inputted value
abs()
returns the smallest integer that is greater than or equal to the number whose ceiling needs to be calculated
ceiling()
returns the largest integer that is smaller than or equal to value passed to it as argument
floor()
series of statements are skipped and jumps to another statement under a particular condition
Branching
Ilegal Variable Names
should not start with number
no other symbols other than underscore
no white spaces
should not start with underscores
no other symbols other than underscore
do not use a reserved code, in this case it is Boolean