title: “Taiwan Stock Market Daily Prices” author: “Delgermaa” date: “r Sys.Date()” output: html_document: toc: true toc_float: true

Код хэсэг knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)

library(readr) library(dplyr) library(ggplot2) library(knitr) 1. Import Data Код хэсэг stock_data <- read.csv(“20261004120300_hw3(20261004120300_hw3)-2.csv”)

head(stock_data) str(stock_data) 2. Data Preparation Код хэсэг stock_data\(Date <- as.Date(stock_data\)Date, format = “%m/%d/%Y”) stock_data\(Open <- parse_number(as.character(stock_data\)Open)) stock_data\(High <- parse_number(as.character(stock_data\)High)) stock_data\(Low <- parse_number(as.character(stock_data\)Low))

str(stock_data) 3. Data Overview Код хэсэг dim(stock_data) names(stock_data) min(stock_data\(Date, na.rm = TRUE) max(stock_data\)Date, na.rm = TRUE) length(unique(stock_data$CO_ID)) 4. Company Summary Код хэсэг company_summary <- stock_data %>% group_by(CO_ID) %>% summarise( Observations = n(), First_Date = min(Date, na.rm = TRUE), Last_Date = max(Date, na.rm = TRUE), Average_Close = mean(Close, na.rm = TRUE), Min_Close = min(Close, na.rm = TRUE), Max_Close = max(Close, na.rm = TRUE), .groups = “drop” )

head(company_summary, 20) 5. Descriptive Statistics Код хэсэг summary(stock_data[, c(“Open”, “High”, “Low”, “Close”)]) 6. Daily Closing Price Visualization Код хэсэг selected_companies <- unique(stock_data$CO_ID)[1:5]

sample_data <- stock_data %>% filter(CO_ID %in% selected_companies)

ggplot(sample_data, aes(x = Date, y = Close, color = as.factor(CO_ID))) + geom_line(linewidth = 0.7) + labs( title = “Daily Closing Prices of Selected Taiwan Stocks”, x = “Date”, y = “Closing Price”, color = “Stock” ) + theme_minimal() 7. Daily Returns Код хэсэг stock_return <- stock_data %>% arrange(CO_ID, Date) %>% group_by(CO_ID) %>% mutate( Daily_Return = Close / lag(Close) - 1 ) %>% ungroup()

head(stock_return) Код хэсэг return_summary <- stock_return %>% group_by(CO_ID) %>% summarise( Average_Return = mean(Daily_Return, na.rm = TRUE), Volatility = sd(Daily_Return, na.rm = TRUE), .groups = “drop” )

head(return_summary, 20) 8. Conclusion This report analyzes daily stock prices of companies listed in the Taiwan stock market.

The dataset contains daily Open, High, Low, and Close prices for 3,599 stocks. The data were cleaned and converted into appropriate formats in R.

Descriptive statistics were calculated for stock prices. Daily closing price trends were also visualized for selected stocks. In addition, daily returns and volatility were calculated to provide further information about stock price movements.