{"id":6440,"date":"2025-10-12T19:30:57","date_gmt":"2025-10-12T11:30:57","guid":{"rendered":"http:\/\/192.168.1.29\/?p=6440"},"modified":"2025-10-12T22:59:42","modified_gmt":"2025-10-12T14:59:42","slug":"r%e7%bb%98%e5%88%b6%e8%82%a1%e7%a5%a8%e6%97%a5%e6%b3%a2%e5%8a%a8%e7%ba%bf%e5%9b%be-%e4%b8%ad%e5%9b%bd%e6%b5%b7%e6%b2%b9600938","status":"publish","type":"post","link":"http:\/\/xc.ipyingshe.net:5347\/?p=6440","title":{"rendered":"R\u7ed8\u5236\u80a1\u7968\u65e5\u6ce2\u52a8\u7ebf\u56fe \u4e2d\u56fd\u6d77\u6cb9600938"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"http:\/\/192.168.1.29\/wp-content\/uploads\/2025\/10\/image-4-1024x640.png\" alt=\"\" class=\"wp-image-6441\" srcset=\"http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-4-1024x640.png 1024w, http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-4-300x187.png 300w, http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-4-768x480.png 768w, http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-4.png 1074w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-2d62d41d-6b41-4973-8636-d2acf64986bd\" href=\"http:\/\/192.168.1.29\/wp-content\/uploads\/2025\/10\/stock_data_numeric.csv\">stock_data_numeric<\/a><a href=\"http:\/\/192.168.1.29\/wp-content\/uploads\/2025\/10\/stock_data_numeric.csv\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-2d62d41d-6b41-4973-8636-d2acf64986bd\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<p>R\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Set the working directory\nsetwd(\"C:\/Users\/czliu\/Documents\/python\")\n\n# Read the CSV file\ndf &lt;- read.csv(\"stock_data_numeric.csv\")\ncolnames(df)\n\n# View the first few rows of the data\nhead(df)\n\n# \u5904\u7406\u7f3a\u5931\u503c\n# df &lt;- read.csv(\"data.csv\", na.strings = c(\"NULL\", \"?\"))  # \u8bfb\u53d6\u6570\u636e\ndf &lt;- na.omit(df)  # \u79fb\u9664\u7f3a\u5931\u503c\n\n# \u8f6c\u6362\u65e5\u671f\u5217\uff08\u786e\u4fdd\u5217\u540d\u6b63\u786e\uff0c\u8fd9\u91cc\u662f\u5c0f\u5199\u7684'date'\uff09\ndf$date &lt;- as.Date(df$date)  # \u5047\u8bbe\u539f\u59cb\u65e5\u671f\u5217\u540d\u4e3a'date'\n\n# \u7ed8\u5236\u7ebf\u56fe\uff08\u4f7f\u7528\u6b63\u786e\u7684\u5217\u540d'date'\uff0c\u4e0e\u4e0a\u9762\u4fdd\u6301\u4e00\u81f4\uff09\nplot(df$close ~ df$date,  # \u8fd9\u91cc\u5c06'Date'\u6539\u4e3a'date'\n     type = \"l\",\n     main = \"Stock Price Daily Change\",\n     xlab = \"Date\",\n     ylab = \"Close Price\",\n     ylim = c(min(df$close), max(df$close))\n)<\/code><\/pre>\n\n\n\n<p><strong>\u56fe\u5f62\u6dfb\u52a0\u5747\u7ebf\uff0c25%\uff0cmedian\uff0c75%\uff0c\u56db\u6761\u7ebf<\/strong>\uff0c\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Set the working directory\nsetwd(\"C:\/Users\/czliu\/Documents\/python\")\n\n# Read the CSV file\ndf &lt;- read.csv(\"stock_data_numeric.csv\")\ncolnames(df)\n\n# View the first few rows of the data\nhead(df)\n\n# \u5904\u7406\u7f3a\u5931\u503c\n# df &lt;- read.csv(\"data.csv\", na.strings = c(\"NULL\", \"?\"))  # \u8bfb\u53d6\u6570\u636e\ndf &lt;- na.omit(df)  # \u79fb\u9664\u7f3a\u5931\u503c\n\n# \u8f6c\u6362\u65e5\u671f\u5217\uff08\u786e\u4fdd\u5217\u540d\u6b63\u786e\uff0c\u8fd9\u91cc\u662f\u5c0f\u5199\u7684'date'\uff09\ndf$date &lt;- as.Date(df$date)  # \u5047\u8bbe\u539f\u59cb\u65e5\u671f\u5217\u540d\u4e3a'date'\n\n# \u7ed8\u5236\u7ebf\u56fe\nplot(df$close ~ df$date,\n     type = \"l\",\n     main = \"Stock Price Daily Change\",\n     xlab = \"Date\",\n     ylab = \"Close Price\",\n     ylim = c(min(df$close), max(df$close))\n)\n\n# \u6dfb\u52a0\u591a\u6761\u6c34\u5e73\u523b\u5ea6\u7ebf--Advanced\n\n# 1. \u5e73\u5747\u503c - \u7ea2\u8272\u865a\u7ebf\nmean_price &lt;- mean(df$close)\nabline(h = mean_price, col = \"red\", lwd = 3, lty = 2)\n\n# 2. \u4e2d\u4f4d\u6570 - \u84dd\u8272\u5b9e\u7ebf\nmedian_price &lt;- median(df$close)\nabline(h = median_price, col = \"blue\", lwd = 3, lty = 1)\n\n\n# 3. \u4e0a\u4e0b\u56db\u5206\u4f4d\u6570 - \u9ed1\u8272\u70b9\u7ebf\nq1_price &lt;- quantile(df$close, 0.25)\nq3_price &lt;- quantile(df$close, 0.75)\nabline(h = q1_price, col = \"black\", lwd = 2, lty = 3)\nabline(h = q3_price, col = \"black\", lwd = 2, lty = 3)\n\n# \u6dfb\u52a0\u56fe\u4f8b\u8bf4\u660e\nlegend(\"topright\", \n       legend = c(paste(\"Mean: \", round(mean_price, 2)),\n                 paste(\"Median: \", round(median_price, 2)),\n                 paste(\"Q1: \", round(q1_price, 2)),\n                 paste(\"Q3: \", round(q3_price, 2))),\n       col = c(\"red\", \"blue\", \"black\", \"black\"),\n       lwd = c(2, 2, 1, 1),\n       lty = c(2, 1, 3, 3),\n       cex = 0.8)\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"1024\" src=\"http:\/\/192.168.1.29\/wp-content\/uploads\/2025\/10\/image-5-683x1024.png\" alt=\"\" class=\"wp-image-6445\" style=\"width:872px;height:auto\" srcset=\"http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-5-683x1024.png 683w, http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-5-200x300.png 200w, http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-5-768x1152.png 768w, http:\/\/xc.ipyingshe.net:5347\/wp-content\/uploads\/2025\/10\/image-5.png 800w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>R\u4ee3\u7801 \u56fe\u5f62\u6dfb\u52a0\u5747\u7ebf\uff0c25%\uff0cmedian\uff0c75%\uff0c\u56db\u6761\u7ebf\uff0c\u4ee3\u7801\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-6440","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/6440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6440"}],"version-history":[{"count":2,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/6440\/revisions"}],"predecessor-version":[{"id":6446,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/6440\/revisions\/6446"}],"wp:attachment":[{"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6440"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xc.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}