最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

NMDS in R

2022-11-12 14:18 作者:農(nóng)夫微甜Kew  | 我要投稿

orders <- read.csv("condensed_order.csv", header = TRUE)

鏈接: https://pan.baidu.com/s/1dQIwcr_gE7v6xFJVKpJ9Wg?pwd=xkeh 提取碼: xkeh 復(fù)制這段內(nèi)容后打開百度網(wǎng)盤手機(jī)App,操作更方便哦

head(orders)


#?First load the vegan package

library(vegan)


nmds_results <- metaMDS(comm = orders[ , 4:11],? # Define the community data?

? ? ? ? ? ? ? ? ? ? ? ? distance = "bray",? ? ? ?# Specify a bray-curtis distance

? ? ? ? ? ? ? ? ? ? ? ? try = 100)? ? ? ? ? ? ? ?# Number of iterations?

nmds_results

##?

## Call:

## metaMDS(comm = orders[, 4:11], distance = "bray", try = 100)?

##?

## global Multidimensional Scaling using monoMDS

##?

## Data:? ? ?wisconsin(sqrt(orders[, 4:11]))?

## Distance: bray?

##?

## Dimensions: 2?

## Stress:? ? ?0.1756999?

## Stress type 1, weak ties

## Two convergent solutions found after 100 tries

## Scaling: centring, PC rotation, halfchange scaling?

## Species: expanded scores based on 'wisconsin(sqrt(orders[, 4:11]))'


#第二步, jump into plot

library(ggplot2)

library(viridis)

#First create a data frame of the scores from the individual sites.

# This data frame will contain x and y values for where sites are located.

data_scores=as.data.frame(scores(nmds_results, display = "sites"))


# Now add the extra aquaticSiteType column?

data_scores <- cbind(data_scores, orders[, 14])

colnames(data_scores)[3] <- "aquaticSiteType"??


# Next, we can add the scores for species data

species_scores <- as.data.frame(scores(nmds_results, "species"))


# Add a column equivalent to the row name to create species labels

species_scores$species <- rownames(species_scores)


# Now we can build the plot!

ggplot() +

? geom_text(data = species_scores, aes(x = NMDS1, y = NMDS2, label = species),

? ? ? ? ? ? alpha = 0.5, size = 8) +?

? geom_point(data = data_scores, aes(x = NMDS1, y = NMDS2,?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?color = aquaticSiteType), size = 3) +

? scale_color_manual(values = inferno(15)[c(3, 8, 11)],

? ? ? ? ? ? ? ? ? ? ?name = "Aquatic System Type") +

? annotate(geom = "label", x = -1, y = 1.25, size = 6,

? ? ? ? ? ?label = paste("Stress: ", round(nmds_results$stress, digits = 3))) +

? theme_minimal() +

? theme(legend.position = "top",

? ? ? ? text = element_text(size = 16))


# 調(diào)整

ggplot() +

? geom_text(data = species_scores, aes(x = NMDS1, y = NMDS2, label = species),

? ? ? ? ? ? alpha = 0.6, size = 6) + #alpha字體顏色深度

? geom_point(data = data_scores, aes(x = NMDS1, y = NMDS2,?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?color = aquaticSiteType), size = 3) +

? scale_color_manual(values = inferno(15)[c(3, 8, 11)],

? ? ? ? ? ? ? ? ? ? ?name = "Aquatic System Type") +

? annotate(geom = "label", x = -1, y = 1.25, size = 6,

? ? ? ? ? ?label = paste("Stress: ", round(nmds_results$stress, digits = 3))) +

? theme_minimal() +

? theme(legend.position = "top",

? ? ? ? text = element_text(size = 16))+

? scale_colour_manual(values = c("orange", "steelblue"))+

? xlim(-2,1)+ ylim(-1.5,1.5)


Code and data source: https://cougrstats.wordpress.com/2019/12/11/non-metric-multidimensional-scaling-nmds-in-r/

NMDS in R的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
怀柔区| 如东县| 横峰县| 雷州市| 都江堰市| 镇巴县| 武乡县| 青田县| 海盐县| 城步| 英山县| 休宁县| 平度市| 通州区| 鄯善县| 南平市| 威信县| 宣汉县| 富锦市| 萝北县| 正镶白旗| 台江县| 方城县| 湟中县| 兴文县| 方城县| 青岛市| 韶山市| 武胜县| 宜良县| 庆安县| 深泽县| 久治县| 红桥区| 株洲市| 剑川县| 东乌珠穆沁旗| 河东区| 石家庄市| 青龙| 郴州市|