# Create sample data with 5 rows and 2 columns
data <- data.frame(a = c(1, 2, 3, 4, 5), # First column values are 1 to 5
b = c(6, 7, 8, 9, 10)) # Second column values are 6 to 10
# Compute cumulative sum of second column
cumulative_sum <- cumsum(data$b)
# Add cumulative sum as a new column to the data frame
data$cumulative_sum <- cumulative_sum
# Print the result
print(data)
## a b cumulative_sum
## 1 1 6 6
## 2 2 7 13
## 3 3 8 21
## 4 4 9 30
## 5 5 10 40