R Flashcards
R language is used for?
data analysis and Statistical Computing
it is especially relevant for data science professionals due to its data cleaning, importing, and visualization capabilities.
R
You can use R to create
graphics and charts
What are the 2 reasons why this language is called R
- R is the first letter in the inventors’ names
- R is a play on the name of its parent language S,
Who developed S language
Bell Telephone Laboratories.
When does R language created
early 1990s
Who created R language?
Ross Ihaka and Robert Gentleman.
Ihaka and Gentleman are both statistics professors in what university?
New Zealand university
How to print/output a text
Use single or double quotes.
Print/output Numbers
Just type the number (without quotes)
Print/output simple calculations’
just type the equation without = sign
Can you output a code without using a print function?
YES
When do you need to use the print()
when your code is inside an expression or inside curly brace { }
What should we use to create a comment in R language
#
Does R language have a command for declaring a variable?
It does not have
<- is use for?
it is use to assign value to a variable
TRUE or FALSE:
To print the variable value, just type the variable name.
TRUE
When you are working with loops, what can you use to print a variable?
print ( ) / print function
it is use to concatenate or join two or more elements
paste ( ) / paste function
In R, we can use this to combine both text and variable
comma ( , )
It can also use to add a variable to another variable
comma ( , )
can you combine a string (text) and a number?
No
TRUE OR FALSE:
You can’t assign the same value to multiple variables in one line.
FALSE
How do we assign the same value to multiple variables?
variable 1 <- variable 2 <- variable 3 <- “Hello world”
TRUE OR FALSE:
A variable name must start with a letter and can be a combination of letters, digits, period(.)
TRUE
TRUE OR FALSE:
A variable name can start with a number or underscore (_)
FALSE
Is Variable name in R language is case-sensitive?
Yes
TRUE or FALSE:
Reserved words can be used as variables
FALSE
Enumerate the Data Types in R language
- Numeric
- Integer
- Complex
- Character
- Logical
Contains any number with or without decimal
Numeric
It is a Numeric data without Decimal
Integer
What should we use at the end of the data type integer?
L
What data type is in this form:
a + bi
Complex
Also known as String
Character
Also known as boolean
Logical
What can we use to check the data type of a variable?
class ( )
What are the 3 Number types in R?
Numeric
Integer
Complex
3 Type conversion
as.numeric()
as.integer()
as.complex()
OPERATORS
*
/
%%
%/%
Build in math functions
min()
max()
sqrt()
abs()
ceiling()
floor()
use to find the lowest number in a set
min()
use to find the largest number in a set
max()
Returns the square root of a number
sqrt()
Returns the absolute value of a number
abs()
Rounds a number upwards to its nearest integer
ceiling()
Rounds a number downwards to its nearest integer
floor()
Is use to find the number of characters in a string
nchar()
Use to check if a character or a sequence of characters are present in a string
grepl()
To merge/concatenate two strings
paste()
what can we use to insert characters that are illegal in a string
Escape Characters
\
Backslash
\n
Newline
\r
Carriage Return
\t
Tab
\b
Backspace
ENUMERATE GRAPHICS IN R
Plot
Line
Scatterplot
Pie charts
bars
what function can we use to plot a point
plot()
what function can we use to create a line
plot ( ) & type parameter
what function can we use to create a scatterplot
Plot()
what function can we use to create a pie chart
pie()
what function can we use to create a bar graph
barplot()