-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit1B.R
39 lines (29 loc) · 1.69 KB
/
Unit1B.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library(readr)
BoeingStock <- read.csv("C:/Users/Nishank/Desktop/SNU/RStuff/BoeingStock.csv", stringsAsFactors = FALSE)
CocaColaStock <- read.csv("C:/Users/Nishank/Desktop/SNU/RStuff/CocaColaStock.csv", stringsAsFactors = FALSE)
GEStock <- read.csv("C:/Users/Nishank/Desktop/SNU/RStuff/GEStock.csv", stringsAsFactors = FALSE)
IBMStock <- read.csv("C:/Users/Nishank/Desktop/SNU/RStuff/IBMStock.csv", stringsAsFactors = FALSE)
ProcterGambleStock <- read.csv("C:/Users/Nishank/Desktop/SNU/RStuff/ProcterGambleStock.csv", stringsAsFactors = FALSE)
str(BoeingStock)
IBMStock$Date = as.Date(IBMStock$Date, "%m/%d/%y")
GEStock$Date = as.Date(GEStock$Date, "%m/%d/%y")
CocaColaStock$Date = as.Date(CocaColaStock$Date, "%m/%d/%y")
ProcterGambleStock$Date = as.Date(ProcterGambleStock$Date, "%m/%d/%y")
BoeingStock$Date = as.Date(BoeingStock$Date, "%m/%d/%y")
nrow(IBMStock)
str(IBMStock)
summary(IBMStock)
min(GEStock$StockPrice)
max(CocaColaStock$StockPrice)
median(BoeingStock$StockPrice)
sd(ProcterGambleStock$StockPrice)
plot(CocaColaStock$Date, CocaColaStock$StockPrice, type = "l", col = "red")
lines(ProcterGambleStock$Date, ProcterGambleStock$StockPrice, col = "blue")
plot(CocaColaStock$Date[301:432], CocaColaStock$StockPrice[301:432], type="l", col="red", ylim=c(0,210))
lines(IBMStock$Date[301:432], IBMStock$StockPrice[301:432], col="blue")
lines(GEStock$Date[301:432], GEStock$StockPrice[301:432], col="purple")
lines(BoeingStock$Date[301:432], BoeingStock$StockPrice[301:432], col="green")
lines(ProcterGambleStock$Date[301:432], ProcterGambleStock$StockPrice[301:432], col="black")
tapply(IBMStock$StockPrice, months(IBMStock$Date),mean)
mean(IBMStock$StockPrice)
tapply(GEStock$StockPrice, months(GEStock$Date),mean)