Arithmetic With Matrices
Arithmetic With Matrices
# Estimation of visitors
visitors <- star_wars_matrix / 5
# Calculate profit
profit <- remaining_tot Budget
Vector to factor
# Definition of hand_vector
hand_vector <- c("Right", "Left", "Left", "Right", "Left")
Factor levels
# Definition of survey_vector
survey_vector <- c("R", "L", "L", "R", "R")
# Print survey_factor
survey_factor
Summarizing a factor
# Defintion of survey_vector and survey_factor
survey_vector <- c("R", "L", "L", "R", "R")
survey_factor <- factor(survey_vector, levels = c("R", "L"), labels = c("Right",
"Left"))
# Summarize survey_vector
summary(survey_vector)
# Summarize survey_factor
summary(survey_factor)
Ordered factors
# Create speed_vector
speed_vector <- c("OK", "Slow", "Slow", "OK", "Fast")
# Print speed_factor
speed_factor
# Summarize speed_factor
summary(speed_factor)
skills 2
RULE THE W II
# Remove economic variables and add population
countries_df_dem <- countries_df[ , c(1, 2, 5)]
countries_df_dem$population <- population
# Add brazil
names(brazil) <- c("name", "continent", "has_president", "population")
countries_df2 <- rbind(countries_df_dem, brazil)
# Sort by population
countries_df2[order(countries_df2$population, decreasing = TRUE), ]
HOW DOES BLAH BLAH
# Subset salaries: salaries_educ
salaries_educ <- salaries[salaries$degree == 3, ]