title: “Activity 3 - R Data Structures” output: html_notebook —
x <- c(10, 20, 30, 40, 50) x
length(x)
colors <- factor(c(“red”, “blue”, “red”, “green”)) colors
levels(colors)
my_list <- list( name = “Joao”, age = 25, scores = c(90, 85, 88) )
my_list my_list\(name my_list\)scores
m <- matrix(1:6, nrow = 2, ncol = 3) m
df <- data.frame( Name = c(“Ana”, “Bob”, “Carlos”), Age = c(22, 25, 30), Grade = c(90, 85, 88) )
df
df$Name df[1, ] df[, 2]
This activity helped me understand the main data structures in R, including vectors, factors, lists, matrices, and data frames. Running the examples made it easier to see how data is organized and accessed in R, which is essential for data analysis.