Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Q1Script.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
library('ggplot2')

data <- read.table(file = 'StockData.txt',header=TRUE)

plot <- ggplot(data, aes(x = AAPL,y = S.P)) +
geom_point() +
xlab('AAPL Daily Return') +
ylab('S&P Daily Return') +
stat_smooth(method = 'lm') +
labs(title = 'Daily Returns of AAPL and S&P500') +
theme_classic()

ggsave('Q1_plot1.jpg', plot = plot, width = 12, height = 8, dpi = 500)

Binary file added Q1_plot1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Q2Script.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
library('ggplot2')

data <- read.table(file = 'data.txt', header = TRUE, sep = ',')

plot1 <- ggplot(data, aes(x = region, y = observations)) +
stat_summary(fun = mean, geom = 'bar') +
scale_y_continuous(expand = c(0,0)) +
theme_classic()

plot2 <- ggplot(data, aes(x = region, y = observations, color = region)) +
geom_jitter() +
scale_y_continuous(expand = c(0,0)) +
theme_classic()

#The two plots tell a different story. The barplot loses some information about the data set
#since it only shows the averages of the data, and nothing about the distribution of the
#points within the set. The scatterplot shows that even though these data have similar means,
#their distribution patterns are different

ggsave('Q2_plot1.jpg', plot = plot1, width = 12, height = 8, dpi = 500)
ggsave('Q2_plot2.jpg', plot = plot2, width = 12, height = 8, dpi = 500)

Binary file added Q2_plot1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Q2_plot2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading