【发布时间】:2017-04-07 14:40:51
【问题描述】:
我正在 R 中实现此分析:下载数据集,创建动物园对象并绘制数据集。
library(tseries)
library(zoo)
start <- "2011-01-01"
end <- "2014-12-31"
MET <- get.hist.quote("MET", quote="Close", start=start, end=end)
MHK <- get.hist.quote("MHK", quote="Close", start=start, end=end)
MJN <- get.hist.quote("MJN", quote="Close", start=start, end=end)
MKC <- get.hist.quote("MKC", quote="Close", start=start, end=end)
MLM <- get.hist.quote("MLM", quote="Close", start=start, end=end)
MMC <- get.hist.quote("MMC", quote="Close", start=start, end=end)
MMM <- get.hist.quote("MMM", quote="Close", start=start, end=end)
MNK <- get.hist.quote("MNK", quote="Close", start=start, end=end)
MNST <- get.hist.quote("MNST", quote="Close", start=start, end=end)
MO <- get.hist.quote("MO", quote="Close", start=start, end=end)
MON <- get.hist.quote("MON", quote="Close", start=start, end=end)
MOS <- get.hist.quote("MOS", quote="Close", start=start, end=end)
MPC <- get.hist.quote("MPC", quote="Close", start=start, end=end)
MRK <- get.hist.quote("MRK", quote="Close", start=start, end=end)
MRO <- get.hist.quote("MRO", quote="Close", start=start, end=end)
Series <- zoo(cbind(MET, MHK, MJN, MKC, MLM, MMC, MMM, MNK, MNST, MO,
MON, MOS, MPC, MRK, MRO))
colnames(Series) <- c("MetLife", "Mohawk", "\nMead\nJohnson",
"McCormick", "Martin\nMarietta",
"Marsh and\nMcLennan", "3M", "Mallinckrodt",
"Monster\nBeverage", "Altria", "Monsanto",
"The Mosaic\nCompany", "Marathon\nPetroleum",
"Merck", "Marathon Oil")
Series <- na.approx(Series)
plot(Series, main = "", xlab = "")
为了呈现更好看的图表,我引入了命令\n 将y标签名称分成两行。但是图形输出将左边的 y 标签放在边距之外。
我尝试修改函数par() 中的mar 和mai,而我的所有输出都没有任何变化。我认为这可能与绘制的对象(动物园对象)相关联。
【问题讨论】: