#to manage data & exibhit operations on it using list data structures
my_list <- list(names = c("Alice", "Bob", "Charlie"),
ages = c(25, 32, 19),
employed = c(TRUE, TRUE, FALSE))
print(my_list)
## $names
## [1] "Alice" "Bob" "Charlie"
##
## $ages
## [1] 25 32 19
##
## $employed
## [1] TRUE TRUE FALSE
print(my_list$names[2])
## [1] "Bob"
my_list$heights <- c(1.65, 1.78, 1.72)
print(my_list)
## $names
## [1] "Alice" "Bob" "Charlie"
##
## $ages
## [1] 25 32 19
##
## $employed
## [1] TRUE TRUE FALSE
##
## $heights
## [1] 1.65 1.78 1.72
mean_age <- mean(my_list$ages)
print(mean_age)
## [1] 25.33333
new_list <- list(names = my_list$names,
employed = my_list$employed)
print(new_list)
## $names
## [1] "Alice" "Bob" "Charlie"
##
## $employed
## [1] TRUE TRUE FALSE