R/plotly 망비록

9000 단어 plotlyR
잘 잊기 때문에 메모.

데이터



UCI machine learning repository의 Water Treatment Plant 데이터. 우선 표준화.
library(plotly)
library(lubridate)
library(dplyr)

# https://archive.ics.uci.edu/ml/datasets/water+treatment+plant
X <- read.csv(file="water-treatment.data", header=FALSE, na.strings="?")
head(X)
X <- na.omit(X)
X <- X %>% mutate(V1=dmy(X$V1)) %>% arrange(V1)
head(X)
X <- X %>% mutate_if(is.numeric, scale) %>% mutate_if(is.numeric, as.numeric)
head(X)

Line-Plots


# line-plot
fig <- plot_ly(x=X$V1, y=X$V2, type="scatter", mode="lines", name="V2")
fig <- fig %>% add_trace(x=X$V1, y=X$V3, name="V3")
fig <- fig %>% add_trace(x=X$V1, y=X$V4, name="V4")
fig <- fig %>% add_trace(x=X$V1, y=X$V5, name="V5")
fig <- fig %>% layout(
  xaxis=list(title="Date"),
  yaxis=list(title="Value"))
fig



히스토그램


# Histogram
fig <- plot_ly(x=X$V2, type="histogram")
fig <- fig %>% layout(
  xaxis=list(title="V2"),
  yaxis=list(title="Count")
)
fig

좋은 웹페이지 즐겨찾기