Visualization in R
Basic Graph Romar Wallen
For my module 8 visualization I chose the Dow Jones stock market file since I have very little knowledge of it and I'd like to see what the value are and how the values are affected by time.
I used this command, DJFranses <- DJFranses[, -1], to remove the first and additional column. This will remove a third element that can issues when running the command for the 2-D graph.
running the code below creates a basic visualization of the DJFranses stock market over the 15 year period.
plot (DJFranses$time, DJFranses$value, cex = 3, pch = 20, main = "Dow index time series data", xlab="Time", ylab = "Stock Value").png)
.png)
Lattice
after loading the library(lattice) into the interface I was able to plot a Lattice graph for the stock that has more values showing more accurate representation of data. You are able to see instances represented by different colors
library(lattice)
latticePlot <- xyplot(value ~ time, data = DJFranses, cex = 1.5, group = time, auto.key = TRUE, main = " DJFranses Stock Market Value/Time Graph\n using Lattice")
GGPLOT
> library(readr) > DJFranses <- read_csv("DJFranses.csv") Rows: 770 Columns: 3 ── Column specification ───────────────────────────────────────────────────────────── Delimiter: "," dbl (3): rownames, time, value ℹ Use `spec()` to retrieve the full column specification for this data. ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. > View(DJFranses) > library(tidyverse) ── Attaching core tidyverse packages ───────────────────────────── tidyverse 2.0.0 ── ✔ dplyr 1.1.2 ✔ purrr 1.0.2 ✔ forcats 1.0.0 ✔ stringr 1.5.0 ✔ ggplot2 3.4.2 ✔ tibble 3.2.1 ✔ lubridate 1.9.2 ✔ tidyr 1.3.0 ── Conflicts ─────────────────────────────────────────────── tidyverse_conflicts() ── ✖ dplyr::filter() masks stats::filter() ✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package to force all conflicts to become errors
> ggplot(data = DJFranses) > > DJFranses <- DJFranses[, -1] > ggplot(data = DJFranses) > > View(DJFranses) > ggplot(data = DJFranses, aes(x = value, y= time)) + geom_point()
> ggplot(data = DJFranses, aes(x = value, y= time)) + geom_point(alpha = .1, aes(color = "red")) .
Comments
Post a Comment