Skip to content

#Categorical variables are the same as "variables discretas" and continous variables relate to the same mathematical meaning that in spanish. It is highly important to recognize whether we are working with categorical variables or continuos one, because the statistical tools we'll use in R depend on this singular variable feature.

#Levels of a factor #Para indicar las categorías de las variables que contiene un vector, debemos usar la función levels(), esta debe ser indicada así: levels(nombre_del_vector_factor) <- c("Categoría1","Categoría2")

# Write and run code here

#summary para ver las características de una variable

Create speed_vector

speed_vector <- c("medium", "slow", "slow", "medium", "fast")

Convert speed_vector to ordered factor vector

factor_speed_vector <- factor(speed_vector, ordered = TRUE, levels = c("slow", "medium", "fast"))

Print factor_speed_vector

factor_speed_vector summary(factor_speed_vector)

#head() and tail() to see the first and last elements of a data frame. #str() to see some of the main features of the data frame variables

Select the rings variable from planets_df

#rings_vector <- planets_df$rings is equal to rings_vector <- planets_df[,3]