5-7 Flashcards
function to find out where NAs are located in data.
is.na()
Which numbers R is representing for True and False?
R represents TRUE as the number 1 and FALSE as the number 0
How to find out how many na in dataset?
What kind of answer does the function yields
sum(is.na(…))
True/False
What do NA and NaN stand for?
not available and not a number
Get the first 10 elements of a vector called x
x[1:10]
Which sign gives us the negation of a logical expression
!
if we want to create a vector called y that contains all of the non-NA| values from x(the dataset)
y
y is a vector. What does y > 0 yields
a vector of logical values the same length as y, with TRUEs corresponding to values of y that are greater than zero and FALSEs corresponding to values of y that are less than or equal to zero.
What do […] do
you want to select some particular elements (i.e. a ‘subset’) from a vector by placing an ‘index vector’ in square brackets
subset the 3rd, 5th, and 7th elements of x
x[c(3,5,7)]
if we’re interested in all elements of x EXCEPT the 2nd and 10th?
x[c(-2, -10)] or better: x[-c(2, 10)]
main difference between matrices and dataframes?
matrices can only contain a single class of data, while data frames can consist of many different classes of data
Can you create a sequence without c()?
you don’t need the c() function when using :
Find out length of a vector
length() function
What does dim() function do? Give an example for every use.
dim() function allows you to get OR set the dim
attribute for an R object.