New to Plotly. Made chart in ggplot but I don’t know how to convert that graph in plotly. Write some code in plotly but it is giving error. Data Attached.
library(ggplot2)
library(dplyr)
library(ggthemes)
library(plotly)
#Setting Working Directory
setwd("C:\\Users\\ShantanuGupta\\Desktop\\Power BI Work")
getwd()
#Data
data <- read.csv("Standards-Change.csv",header=TRUE)
data1 <- read.csv("Standards-Change.csv",header=TRUE)
# Keep 8 category
data <- data %>%
filter(Category %in% c("'+1SD", "'+2SD", "'+3SD","'-1SD","'-2SD","'-3SD","ExpectedValue","Result"))
#Plot
myColors = c("#999999", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
#ggplot
data %>%
ggplot(aes(x=DateSampleID, y=Average.of.Value, group=Category, color=Category)) +
geom_line(size=0.5, alpha=0.8)+
labs(title = "Standards",
subtitle = "How do Au_PPM differ by SampleID?",
x = "DateSampleID",
y = "Result",
color = "Region") +
theme_minimal()+
theme( axis.text.x=element_blank(), axis.ticks.x=element_blank())+
scale_color_manual(values = myColors)
#plotly
data1%>%
group_by(Category)%>%
summarise(models=n())%>%
plot_ly(x=~DateSampleID,
y=~Average.of.Value,
group=~Category,
type="line",
color=~Category,
)