R Flashcards
assign a value to a variable
use
determining that the object (murders dataset) is of the “data frame” class
class(murders)
finding out more about the structure of the object
str(murders)
showing the first 6 lines of the dataset
head(murders)
obtain a specific column (ex population)
murders$population
$ is called accessor operator
displaying the variable names in the murders dataset
names(murders)
determining how many entries are in a vector
pop
obtaining the levels of a factor
levels(murders$region)
obtaining the number of levels of a factor
nlevels()
create vectors of class numeric or character
use “concentrate function”
ex: codes
name the elements of a numeric vector
codes
name the elements of a numeric vector in a different way
codes
access specific elements of a vector
Using square brackets
The function ____ sorts a vector in increasing order.
sort()
The function _____ produces the indices needed to obtain the sorted vector
order()
The function ____ gives us the ranks of the items in the original vector
rank()