%load_ext rmagic
%%R
library(vegan)
Carico il pacchetto richiesto: permute This is vegan 2.0-7
%%R
spmat<-read.csv("http://epi.whoi.edu/ipython/results/mdistefano/pg_site1_sp.csv",header=T)
%%R
print(head(spmat))
idcode count temp sal depth_m subs imagename 1 10008 24 4.340 32.870 113.93 35 UNQ.20080414.185740001.153940.jpg 2 10008 1 4.337 32.863 107.72 35 UNQ.20080414.162454480.112576.jpg 3 10008 22 4.313 32.854 118.14 35 UNQ.20080414.191746242.159726.jpg 4 10008 1 4.340 32.854 75.53 35 UNQ.20080414.162617217.112966.jpg 5 10008 22 4.347 32.872 120.88 35 UNQ.20080414.185350754.152830.jpg 6 10008 1 4.340 32.853 74.25 35 UNQ.20080414.162623452.112996.jpg st_x st_y 1 -70.27453 42.60262 2 -70.27663 42.60385 3 -70.27008 42.61063 4 -70.27915 42.60378 5 -70.27468 42.60742 6 -70.27930 42.60378
%%R
dd <- na.omit(spmat)
dd1 <- dd[3:6]
print(head(dd1))
temp sal depth_m subs 1 4.340 32.870 113.93 35 2 4.337 32.863 107.72 35 3 4.313 32.854 118.14 35 4 4.340 32.854 75.53 35 5 4.347 32.872 120.88 35 6 4.340 32.853 74.25 35
%%R
distmat1<-vegdist(dd1)
%%R
clusa1<-hclust(distmat1,"average")
%%R
print(clusa1)
Call: hclust(d = distmat1, method = "average") Cluster method : average Distance : bray Number of objects: 6733
%%R
print(dend1 <- as.dendrogram(clusa1))
'dendrogram' with 2 branches and 6733 members total, at height 0.2297601
%%R
plot(dend1)
%%R
dend12 <- cut(dend1, h=0.06)
plot(dend12$upper)
plot(dend12$lower[[1]])
lines = !jist -p hclust.ipynb
print lines[0].replace("https://gist.github.com", "http://nbviewer.ipython.org")
http://nbviewer.ipython.org/5499744