
# Create example data
my_data <- data.frame(x1 = 1:5,            
                      x2 = 2:6,
                      x3 = 3)

print(paste0("Initial array values:",collapse=" "))
my_data                      

# invoke the apply() function:
print(paste0("Row-wise sum of values:",collapse=" "))
apply(my_data, 1, sum)

print(paste0("Column-wise sum of values:",collapse=" "))
apply(my_data, 2, sum)

# Create example list:
my_list <- list(1:5,
                letters[1:3],
                777)

# Print example list:
my_list

# invoke the lapply() function:
lapply(my_list, length)

# invoke the sapply() function:
sapply(my_list, length)
# 5 3 1

# invoke the vapply() function:
vapply(my_list, length, integer(1))

