# Required Libraries
install.packages('ggplot2', repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/shivs/OneDrive/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## package 'ggplot2' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\shivs\AppData\Local\Temp\Rtmpy2BDeR\downloaded_packages
install.packages('plotly', repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/shivs/OneDrive/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## package 'plotly' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\shivs\AppData\Local\Temp\Rtmpy2BDeR\downloaded_packages
install.packages('htmlwidgets', repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/shivs/OneDrive/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## package 'htmlwidgets' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\shivs\AppData\Local\Temp\Rtmpy2BDeR\downloaded_packages
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(htmlwidgets)
# Importing dataset
v1 <- read.csv("C:/Users/shivs/Downloads/v1.csv")
# Creating the plot
p <- ggplot(v1, aes(x, y, fill= Frequency, label = Space.Name)) +
geom_tile() +
geom_label(fill = "white") +
scale_fill_gradient(low="white", high="red3") +
theme(axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank()) +
ggtitle("Monopoly Board Space Frequencies")
pp <- ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLabel() has yet to be implemented in plotly.
## If you'd like to see this geom implemented,
## Please open an issue with your example code at
## https://github.com/ropensci/plotly/issues
saveWidget(pp, file=paste0( getwd(), "/ggplotlyHeatmap.html"))
pp
# Required Libraries
install.packages('chorddiag', repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/shivs/OneDrive/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## Warning: package 'chorddiag' is not available for this version of R
##
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
install.packages('htmlwidgets',repos = "http://cran.us.r-project.org")
## Warning: package 'htmlwidgets' is in use and will not be installed
library(chorddiag)
library(htmlwidgets)
# Importing datasets
v2 <- read.csv("C:/Users/shivs/Downloads/v2.csv")
spaces <- read.csv("C:/Users/shivs/Downloads/spaces.csv")
# Converting list of edges into adjacency matrix, then into dataframe
adjacencyData <- with(v2, table(v2$I_current, v2$I_next))
m <- as.matrix(adjacencyData)
df = data.frame("Go" = m[, 1])
for(i in 2:40){
name <- spaces[i, 2]
df[name] <- m[, i]
}
df = as.matrix(df)
# Creating the plot
viz_2 <- chorddiag(df, type = "directional", showTicks = F,
groupnameFontsize = 7, groupnamePadding = 10, margin = 90)
## Warning in chorddiag(df, type = "directional", showTicks = F, groupnameFontsize
## = 7, : row names of the 'data' matrix differ from its column names or the
## 'groupNames' argument.
## Warning in RColorBrewer::brewer.pal(n, palette): n too large, allowed maximum for palette Dark2 is 8
## Returning the palette you asked for with that many colors
saveWidget(viz_2, file=paste0( getwd(), "/chord_interactive.html"))
viz_2
# Required Libraries
install.packages('ggplot2', repos = "http://cran.us.r-project.org")
## Warning: package 'ggplot2' is in use and will not be installed
library(ggplot2)
# Importing the dataset
v3 <- read.csv("C:/Users/shivs/Downloads/v3.csv")
# Creating the plot
ggplot(v3, aes(x=Space.Name, y=Profit, fill = Space.Name)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = c("brown4", "chocolate1", "forestgreen") ) +
theme(legend.position="none") +
ggtitle("The most profitable Community Chest") +
xlab("Space") +
ylab("Profit (in $)")
# Required Libraries
install.packages("networkD3", repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/shivs/OneDrive/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## package 'networkD3' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\shivs\AppData\Local\Temp\Rtmpy2BDeR\downloaded_packages
install.packages("dplyr", repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/shivs/OneDrive/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## package 'dplyr' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'dplyr'
## Warning in file.copy(savedcopy, lib, recursive = TRUE):
## problem copying C:\Users\shivs\OneDrive\Documents\R\win-
## library\4.0\00LOCK\dplyr\libs\x64\dplyr.dll to C:
## \Users\shivs\OneDrive\Documents\R\win-library\4.0\dplyr\libs\x64\dplyr.dll:
## Permission denied
## Warning: restored 'dplyr'
##
## The downloaded binary packages are in
## C:\Users\shivs\AppData\Local\Temp\Rtmpy2BDeR\downloaded_packages
install.packages("htmlwidgets", repos = "http://cran.us.r-project.org")
## Warning: package 'htmlwidgets' is in use and will not be installed
library(networkD3)
##
## Attaching package: 'networkD3'
## The following object is masked from 'package:htmlwidgets':
##
## JS
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(htmlwidgets)
# Importing the dataset
viz_4 <- read.csv("C:/Users/shivs/Downloads/v4.csv")
# Instantiating Chance #1 as the source for all edges
viz_4$From = c("Chance #1")
# Removing Chance #1 as a destination
v4 <- viz_4[-c(4), ]
nodes <- data.frame(
name=c(as.character(v4$From),
as.character(v4$Space.Name)) %>% unique()
)
v4$IDsource <- match(v4$From, nodes$name)-1
v4$IDtarget <- match(v4$Space.Name, nodes$name)-1
plot <- sankeyNetwork(Links = v4, Nodes = nodes,
Source = "IDsource", Target = "IDtarget",
Value = "Count", NodeID = "name",
fontSize = 14, fontFamily = "arial",
sinksRight=FALSE)
saveWidget(plot, file=paste0( getwd(), "/sankeyChance.html"))
plot
# Required Libraries
install.packages('ggplot2', repos = "http://cran.us.r-project.org")
## Warning: package 'ggplot2' is in use and will not be installed
install.packages('plotly', repos = "http://cran.us.r-project.org")
## Warning: package 'plotly' is in use and will not be installed
install.packages('htmlwidgets', repos = "http://cran.us.r-project.org")
## Warning: package 'htmlwidgets' is in use and will not be installed
library(ggplot2)
library(plotly)
library(htmlwidgets)
# Importing dataset
v5 <- read.csv("C:/Users/shivs/Downloads/v5.csv")
# Creating the plot
p5 <- ggplot(v5, aes(x, y, fill= benefit, label = Space.Name)) +
geom_tile() +
geom_label(fill = "white") +
scale_fill_gradient(low="white", high="green4") +
theme(axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank()) +
ggtitle("Monopoly Board Space Profitability")
p5_i <- ggplotly(p5)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLabel() has yet to be implemented in plotly.
## If you'd like to see this geom implemented,
## Please open an issue with your example code at
## https://github.com/ropensci/plotly/issues
saveWidget(p5_i, file=paste0( getwd(), "/moneyHeatmap.html"))
p5_i