Justus Krupp, Germany

library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
# Function to add a row to the table
add_row <- function(category, symbol) {
  data <- getSymbols(symbol, src = "yahoo", auto.assign = FALSE)
  last_price <- as.numeric(last(Cl(data)))
  table_data <<- rbind(table_data, data.frame(
    Name = category,
    Number = last_price
  ))
}

# Initialize the data frame
table_data <- data.frame(
  Beginning_of_Term = character(),
  End_of_Term = numeric()
)

# Stock market index information
add_row("S&P 500 (stock) index level:", "^GSPC")
add_row("Nasdaq Composite (stock) index level:", "^IXIC")

# ... other categories and symbols

# Display the table
print(table_data)
##                                    Name   Number
## 1          S&P 500 (stock) index level:  5916.98
## 2 Nasdaq Composite (stock) index level: 18987.47