R/glasso+igraph+networkD3で変数間の関係をインタラクティブに可視化②
せっかくなんでSpecies毎に可視化。
library(dplyr)
library(glasso)
library(igraph)
library(networkD3)
f <- function(x){
x <- iris %>% filter(Species == x) %>% select(-Species)
print(dim(x))
s <- x %>% scale() %>% cov()
fit <- glasso(s = s, rho = 0.5)
a <- ifelse(fit$wi != 0, TRUE, FALSE)
diag(a) <- 0
colnames(a) <- colnames(x)
rownames(a) <- colnames(x)
g <- graph_from_adjacency_matrix(a, mode = "undirected")
networkData <- as.data.frame(as_edgelist(g))
return(simpleNetwork(Data = networkData, fontSize = 14, nodeColour = "#006e54", opacity = 1))
}
f("setosa")
f("versicolor")
f("virginica")
Species == "setosa"
Species == "versicolor"
Species == "vriginica"
Author And Source
この問題について(R/glasso+igraph+networkD3で変数間の関係をインタラクティブに可視化②), 我々は、より多くの情報をここで見つけました https://qiita.com/yono2844/items/3ac45332e90646795a98著者帰属:元の著者の情報は、元の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 .