R/plotlyの忘備録
良く忘れるのでメモ。
データ
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
# 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
# Histogram
fig <- plot_ly(x=X$V2, type="histogram")
fig <- fig %>% layout(
xaxis=list(title="V2"),
yaxis=list(title="Count")
)
fig
Author And Source
この問題について(R/plotlyの忘備録), 我々は、より多くの情報をここで見つけました https://qiita.com/yono2844/items/4a27f8b74dd31e20221d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .