Why R? - used in financial service, academia, healthcare and more
- powerful data visualization tool
- write programs to analyze data and produce a report
Reasons why a set of code would produce an error? - - functions need both an open
and close parentheses to operate on whats inside
- indentations do not produce error, but its not recommended to have random
indents for readability
- functions are CASE SENSATIVE
whats str( ) - helps us understand the type of object we are working with
how can we save objects in R? - using the assignment arrow
<-
how do we generate basics plots> - using the
plot( )
function
how can we generate summary statistics> - using the
summary ( )
function
REVIEW Day 3 Warmup - found on slides 6-7
What type of vector is aVector?
aVector<-c(1, 2, 5) - 1, 2, and 5 are all numbers (doubles), so aVector type is a
double
What type of vector is bVector?
bVector <-c(1, 2, "a") - "a" is a character... because of this, R is going to make 1 and
2 characters as well, and the type of bVector will be a character!
Vectors are ordered collections of ____ elements - Homogeneous
Lists are ordered collections of ______ elements - heterogeneous
Data frames are a special list type but are made with the data.frame () function -
Data Frames are a named list of vectors which are all of equal lengths
The function ____ helps combine elements - c()
We can index with - [ ] (vectors)
[[ ]] (lists)
install.packages ( ) - takes the R package, and locally install it in our library
- buy the clothes and putting them in your closet
, library ( ) - "opens up" the package for use to use the functionalities --> getting you
clothes out of the closet and wearing them
dplyr::pull ( ) - dplyr is the package
:: is the syntax between the package and the argument
pull ( ) is a function being called from the dplyr package
:: helps us .... - use a function from a specific package
If you look at the help file for a function and see an argument in the function
definition with an = sign and a value next to it, for example
runif(n, min = 0, max = 1),
what does the value to the right of the equal sign represent?
a.An example of what you might put in as the input for that argument but the value
isn't actually used.
b. If the user doesn't specify a value for that argument, this is the default value to
use.
c.The value of the argument any time the function is called. - b. If the user doesn't
specify a value for that argument, this is the default value to use.
In the above console, type print(cars) on one line and print(exp) on another. Submit
the code.
Why does print(cars) produce a different type of output than print(exp)?
a. R is determining how to use print() based on the type of object used as the input
b. R doesn't know how to print every type of object
c. R is running into an error
d. the cars object was loaded in from an external file - a. R is determining how to use
print() based on the type of object used as the input
There is a built-in R object called (note that R is case-sensitive):
letters
What is the class of the letters object?
Simply give the name of the class as your answer - character
What is the purpose of the R console?
The console is where
a.you easily write code to save for later use
b.the help file associated with an R function appears
c.code is submitted to be evaluated.
d.you can locate plots that have been created - c.code is submitted to be evaluated.
When you create an object in an R session, in which pane of the RStudio IDE can
you see the object?
a. the environment pane