当前位置:网站首页>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)
)
边栏推荐
- Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
- Analyse de l'industrie
- MySQL comparison operator in problem solving
- [visual studio 2019] create and import cmake project
- Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
- ROS lacks xacro package
- HOW TO CREATE A BEAUTIFUL INTERACTIVE HEATMAP IN R
- 揭露数据不一致的利器 —— 实时核对系统
- 文件操作(详解!)
- Summary of data export methods in powerbi
猜你喜欢

pgsql 字符串转数组关联其他表,匹配 拼接后原顺序展示

Solve the problem of data blank in the quick sliding page of the uniapp list

基于Hardhat和Openzeppelin开发可升级合约(二)

Wechat applet uses Baidu API to achieve plant recognition

map集合赋值到数据库

Eight sorting summaries

Some problems encountered in introducing lvgl into esp32 Arduino

MySQL linked list data storage query sorting problem

Research on and off the Oracle chain

Amazon cloud technology community builder application window opens
随机推荐
Some suggestions for young people who are about to enter the workplace in the graduation season
bedtools使用教程
RPA advanced (II) uipath application practice
ROS lacks catkin_ pkg
GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R
Programmer growth Chapter 6: how to choose a company?
Writing contract test cases based on hardhat
C#基于当前时间,获取唯一识别号(ID)的方法
【2022 ACTF-wp】
Pyqt5+opencv project practice: microcirculator pictures, video recording and manual comparison software (with source code)
How to Easily Create Barplots with Error Bars in R
基于Hardhat和Openzeppelin开发可升级合约(一)
2022年遭“挤爆”的三款透明LED显示屏
ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
Visualization of chip SEQ data by deeptools
GGPlot Examples Best Reference
The position of the first underline selected by the vant tabs component is abnormal
2022年4月17日五心红娘团队收获双份喜报
to_bytes与from_bytes简单示例
php 二维、多维 数组打乱顺序,PHP_php打乱数组二维数组多维数组的简单实例,php中的shuffle函数只能打乱一维
