R studio Chapter 1 Flashcards
R lab comment starts with?
#
Assign value 42 to a variable X
x< -42
The quotation marks” “ is to indicate…
the variable is of type character.
What are Numerics, integers, logical?
Numerics are decimal values like 4.5. Integers are also numerics but in natural numbers. Logical is boolean values like TRUE or FALSE.
Class()
It checks the type of data.
Is.character(v)
It checks if a variable is a character.
what are commands for coercion for taming the data?
as.logical(), as.numeric(), as.integer(), as.character()
Create a vector.
c( , )
Select the letter “a” from character_vector
character_vector (“a”, “b”, “c”)
character_vector [1]
Select the second and the third element of boolean_vector boolean_vector c(TRUE, FALSE, FALSE)
boolean_vector [c(2,3)]
for less than, for more than, for less than and equal to, for more than and equal to, equal to each other, not equal to each other
< > <= >= == !=
Print the items from numeric_vector that are larger than 10 numeric_vector c(1, 10, 35)
numeric_vector [c(FALSE, FALSE, TRUE)]
Construct a matrix with 5 rows and 4 columns containing the numbers 1 up to 20 and assign it to the variable m. Specify the byrow argument to be TRUE
matrix(1:20, byrow=TRUE, nrow=5, ncol=4)
The term factor refers to…?
A good example of a categorical variable is?
Command for turning vector into a factor?
a statistical data type used to store categorical variables. Categorical variables, unlike continuous variables, have a limited range.
“student” and “not student” are two values of the categorical variable.
factor (variable)
functions to inspect the dataframes:
What command prints the first 6 rows of the dataframe?
What command prints the last 6 rows?
What command prints the structure of your dataframe?
What command prints the dimensions, that is, the number of rows and columns of your dataframe?
What command prints the names of the columns of your dataframe?
head tail str dim colnames