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")

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()



I was able to change the color

> ggplot(data = DJFranses, aes(x = value, y= time)) + geom_point(alpha = .1, aes(color = "red")) .




Conclusions: Base Graphs are the most straight forward and less time consuming,  for analysing or looking at multiple values , I think Lattice is good for that kind of visualization. GGplot is very interesting , I am amateur level , so I don't think I will be expanding on GGplot however I would like to learn more about these visualization and I hope to improve my understand during my Final project. 

Comments

Popular posts from this blog

R secure coding

Mod 11 debugging

Final Project-R Package