当前位置:网站首页>Seriation in R: How to Optimally Order Objects in a Data Matrice
Seriation in R: How to Optimally Order Objects in a Data Matrice
2022-07-02 11:50:00 【Xiaoyu 2022】
library(seriation)
# Load the data
data("iris")
df <- iris
head(df, 2)
# Remove the column `species` (column 5)
df <- df[, -5]
# Reorder the objects randomly
set.seed(123)
df <- df[sample(seq_len(nrow(df))),]
head(df, 2)
# Compute dissimilarity matrix
dist_result <- dist(df)
# Seriate objects, reorder rows based on their similarity
object_order <- seriate(dist_result)
# Extract object orders
head(get_order(object_order), 15)
pimage(dist_result, main = "Random order")
library(seriation)
# Load the data
data("iris")
df <- iris
head(df, 2)
# Remove the column `species` (column 5)
df <- df[, -5]
# Reorder the objects randomly
set.seed(123)
df <- df[sample(seq_len(nrow(df))),]
head(df, 2)
# Compute dissimilarity matrix
dist_result <- dist(df)
# Seriate objects, reorder rows based on their similarity
object_order <- seriate(dist_result)
# Extract object orders
head(get_order(object_order), 15)
pimage(dist_result, order = object_order, main = "Reordered")
library(seriation)
# Data preparation
# Load the dataset
data("USArrests")
# Replace original values by their ranks
df <- head(apply(USArrests, 2, rank), 30)
# Perform seriation on row and columns
row_order <- seriate(dist(df, "minkowski", p = 1), method ="TSP")
col_order <- seriate(dist(t(df), "minkowski", p = 1), method ="TSP")
orders <- c(row_order, col_order)
# Visualization: matrix of bars
# Original matrix
bertinplot(df)
library(seriation)
# Data preparation
# Load the dataset
data("USArrests")
# Replace original values by their ranks
df <- head(apply(USArrests, 2, rank), 30)
# Perform seriation on row and columns
row_order <- seriate(dist(df, "minkowski", p = 1), method ="TSP")
col_order <- seriate(dist(t(df), "minkowski", p = 1), method ="TSP")
orders <- c(row_order, col_order)
# Visualization: matrix of bars
# Original matrix
bertinplot(df, orders)
library(seriation)
# Load demo data
data("Townships")
# Visualize the original data
bertinplot(
Townships,
options = list(panel = panel.circles)
)
library(seriation)
# Load demo data
data("Townships")
# Seriate rows and columns using the bond energy algorithm (BEA)
set.seed(1234)
orders <- seriate(Townships, method = "BEA", control = list(rep = 10))
bertinplot(
Townships, order = orders,
options = list(panel = panel.circles)
)
边栏推荐
猜你喜欢
How to Create a Beautiful Plots in R with Summary Statistics Labels
K-Means Clustering Visualization in R: Step By Step Guide
揭露数据不一致的利器 —— 实时核对系统
HOW TO EASILY CREATE BARPLOTS WITH ERROR BARS IN R
Mmrotate rotation target detection framework usage record
多文件程序X32dbg动态调试
[idea] use the plug-in to reverse generate code with one click
How to Easily Create Barplots with Error Bars in R
基于Hardhat和Openzeppelin开发可升级合约(一)
Principe du contrat évolutif - delegatecall
随机推荐
PX4 Position_ Control RC_ Remoter import
[visual studio 2019] create MFC desktop program (install MFC development components | create MFC application | edit MFC application window | add click event for button | Modify button text | open appl
ROS lacks catkin_ pkg
[visual studio 2019] create and import cmake project
程序员成长第六篇:如何选择公司?
Develop scalable contracts based on hardhat and openzeppelin (II)
Thesis translation: 2022_ PACDNN: A phase-aware composite deep neural network for speech enhancement
HOW TO ADD P-VALUES TO GGPLOT FACETS
php 根据经纬度查询距离
Some problems encountered in introducing lvgl into esp32 Arduino
PX4 Position_Control RC_Remoter引入
时间格式化显示
php 二维、多维 数组打乱顺序,PHP_php打乱数组二维数组多维数组的简单实例,php中的shuffle函数只能打乱一维
Eight sorting summaries
BEAUTIFUL GGPLOT VENN DIAGRAM WITH R
Take you ten days to easily finish the finale of go micro services (distributed transactions)
PgSQL string is converted to array and associated with other tables, which are displayed in the original order after matching and splicing
6. Introduce you to LED soft film screen. LED soft film screen size | price | installation | application
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
2022年遭“挤爆”的三款透明LED显示屏