I want a surface plot, but my grid is incomplete. I searched, but without success. How can I make the following work:
x = c(10L, 20L, 30L, 40L, 50L, 60L, 70L, 80L, 90L, 100L, 30L, 40L,
50L, 60L, 70L, 80L, 90L, 100L, 50L, 60L, 70L, 80L, 90L, 100L,
70L, 80L, 90L, 100L, 90L, 100L)
y = c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 30L, 30L, 30L, 30L, 30L, 30L,
40L, 40L, 40L, 40L, 50L, 50L)
z = c(6.093955007, 44.329214443, 149.103755156, 351.517349974,
726.51174655, 1191.039562104, 1980.245204702, 2783.308022984,
6974.563519067, 5149.396230019, 142.236259009, 321.170609648,
684.959503897, 1121.475597135, 1878.334840961, 2683.116309688,
4159.60732066, 5294.774284119, 687.430547359, 1119.765405426,
1876.57337196, 2685.951176024, 3945.696884503, 5152.986796572,
1870.78724464, 2677.744176903, 3951.928931107, 5160.295960254,
3957.503273558, 5147.237754092)
# OK but not a surface plot
scatterplot3d::scatterplot3d(x, y, z,
color = "blue", pch = 19,
type = "h",
main = "",
xlab = "x",
ylab = "y",
zlab = "z",
angle = 35,
grid = FALSE)
# Not working:
M <- plot3D::mesh(x, y, z)
R <- with (M, sqrt(x^2 + y^2 +z^2))
p <- sin(2*R)/(R+1e-3)
plot3D::slice3D(x, y, z, colvar = p,
xs = 0, ys = c(-4, 0, 4), zs = NULL)
plot3D::isosurf3D(x, y, z, colvar = p, level = 0, col = "red")
For this kind of problem I can recommend the deldir-package which does "Delaunay triangulation and Dirichlet tessellation". From this you calculate the spacial triangles that give the surface plot.
The rgl-package gives the possibility to add the triangles to your scatterplot. And even better - the resulting plot is animated, so you can rotate and zoom for better overview.
x = c(10L, 20L, 30L, 40L, 50L, 60L, 70L, 80L, 90L, 100L, 30L, 40L,
50L, 60L, 70L, 80L, 90L, 100L, 50L, 60L, 70L, 80L, 90L, 100L,
70L, 80L, 90L, 100L, 90L, 100L)
y = c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 30L, 30L, 30L, 30L, 30L, 30L,
40L, 40L, 40L, 40L, 50L, 50L)
z = c(6.093955007, 44.329214443, 149.103755156, 351.517349974,
726.51174655, 1191.039562104, 1980.245204702, 2783.308022984,
6974.563519067, 5149.396230019, 142.236259009, 321.170609648,
684.959503897, 1121.475597135, 1878.334840961, 2683.116309688,
4159.60732066, 5294.774284119, 687.430547359, 1119.765405426,
1876.57337196, 2685.951176024, 3945.696884503, 5152.986796572,
1870.78724464, 2677.744176903, 3951.928931107, 5160.295960254,
3957.503273558, 5147.237754092)
# create spacial triangles
del <- deldir::deldir(x, y, z = z)
triangs <- do.call(rbind, triang.list(del))
# create plot
rgl::plot3d(x, y, z, size = 5, xlab = "my_x", ylab = "my_y", zlab = "my_z", col = "red")
rgl::triangles3d(triangs[, c("x", "y", "z")], col = "gray")
I hope this helps.
This is more of a hint than a complete answer:
library(plotly)
plot_ly(z = ~volcano) %>% add_surface()
is a nice way to do this kind of plots. So for your example:
x <- c(10L, 20L, 30L, 40L, 50L, 60L, 70L, 80L, 90L, 100L, 30L, 40L,
50L, 60L, 70L, 80L, 90L, 100L, 50L, 60L, 70L, 80L, 90L, 100L,
70L, 80L, 90L, 100L, 90L, 100L)
y <- c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 30L, 30L, 30L, 30L, 30L, 30L,
40L, 40L, 40L, 40L, 50L, 50L)
z <- c(6.093955007, 44.329214443, 149.103755156, 351.517349974,
726.51174655, 1191.039562104, 1980.245204702, 2783.308022984,
6974.563519067, 5149.396230019, 142.236259009, 321.170609648,
684.959503897, 1121.475597135, 1878.334840961, 2683.116309688,
4159.60732066, 5294.774284119, 687.430547359, 1119.765405426,
1876.57337196, 2685.951176024, 3945.696884503, 5152.986796572,
1870.78724464, 2677.744176903, 3951.928931107, 5160.295960254,
3957.503273558, 5147.237754092)
library(plotly)
m <- matrix(c(x,y,z), nrow = 3)
plot_ly(z = ~m) %>% add_surface()
produces
..this is a first step, but there's still some issues with the scaling of the x-axis. I think key to the solution is to set up the whole (sparse) matrix and then plot it.
x <- c(10L, 20L, 30L, 40L, 50L, 60L, 70L, 80L, 90L, 100L, 30L, 40L,
50L, 60L, 70L, 80L, 90L, 100L, 50L, 60L, 70L, 80L, 90L, 100L,
70L, 80L, 90L, 100L, 90L, 100L)
y <- c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 30L, 30L, 30L, 30L, 30L, 30L,
40L, 40L, 40L, 40L, 50L, 50L)
z <- c(6.093955007, 44.329214443, 149.103755156, 351.517349974,
726.51174655, 1191.039562104, 1980.245204702, 2783.308022984,
6974.563519067, 5149.396230019, 142.236259009, 321.170609648,
684.959503897, 1121.475597135, 1878.334840961, 2683.116309688,
4159.60732066, 5294.774284119, 687.430547359, 1119.765405426,
1876.57337196, 2685.951176024, 3945.696884503, 5152.986796572,
1870.78724464, 2677.744176903, 3951.928931107, 5160.295960254,
3957.503273558, 5147.237754092)
xx <- 1:100L
yy <- 1:100L
zz <- matrix(0, nrow = 100, ncol = 100)
for (i in 1:length(x)){
zz[x[i], y[i]] <- z[i]
}
library(plotly)
plot_ly(z = ~zz) %>% add_surface()
produces
which is basically what your data supposes..
Hope I can figure that out as well.
And hope this helps.
Related
I've been trying to find a way to convert text files with pixels values into images (no matter the format) in R but I couldn't find a way to do it.
I found solutions for MatLab and Python, for example.
I have a file with 520 x 640 pixels with values from 0 to 255.
This is a small piece of it.
mid1al <- read.table("C:/Users/u015/Mid1_R_Al.txt", header = FALSE, sep = ";")
mid1al <- mid1al[1:20,1:20]
dput(mid1al)
structure(list(V1 = c(84L, 79L, 97L, 67L, 98L, 113L, 77L, 46L,
41L, 37L, 42L, 46L, 23L, 28L, 24L, 34L, 45L, 51L, 24L, 24L),
V2 = c(118L, 107L, 105L, 82L, 87L, 108L, 100L, 40L, 71L,
74L, 81L, 55L, 41L, 25L, 22L, 58L, 53L, 38L, 26L, 36L), V3 = c(103L,
116L, 128L, 82L, 77L, 104L, 97L, 50L, 65L, 78L, 98L, 111L,
86L, 59L, 35L, 51L, 43L, 46L, 33L, 47L), V4 = c(114L, 91L,
90L, 96L, 103L, 98L, 86L, 36L, 50L, 65L, 98L, 125L, 86L,
32L, 24L, 36L, 36L, 44L, 34L, 43L), V5 = c(68L, 70L, 85L,
85L, 100L, 111L, 61L, 12L, 42L, 70L, 103L, 103L, 45L, 27L,
18L, 27L, 32L, 43L, 51L, 41L), V6 = c(43L, 87L, 85L, 89L,
130L, 123L, 78L, 43L, 15L, 39L, 62L, 44L, 27L, 14L, 19L,
61L, 83L, 90L, 88L, 88L), V7 = c(20L, 72L, 116L, 124L, 133L,
133L, 103L, 56L, 21L, 9L, 19L, 26L, 18L, 32L, 67L, 92L, 100L,
105L, 94L, 79L), V8 = c(69L, 96L, 120L, 144L, 142L, 101L,
96L, 46L, 14L, 4L, 8L, 2L, 24L, 73L, 96L, 106L, 103L, 116L,
109L, 74L), V9 = c(118L, 122L, 134L, 135L, 133L, 98L, 57L,
20L, 5L, 5L, 2L, 14L, 51L, 89L, 117L, 95L, 103L, 93L, 104L,
77L), V10 = c(122L, 107L, 127L, 147L, 128L, 88L, 24L, 11L,
10L, 4L, 10L, 31L, 74L, 104L, 113L, 107L, 109L, 99L, 103L,
45L), V11 = c(105L, 120L, 114L, 132L, 125L, 112L, 51L, 6L,
3L, 9L, 18L, 49L, 82L, 111L, 111L, 96L, 92L, 81L, 75L, 18L
), V12 = c(98L, 104L, 103L, 126L, 147L, 128L, 61L, 26L, 2L,
9L, 18L, 50L, 105L, 103L, 101L, 98L, 74L, 53L, 18L, 1L),
V13 = c(107L, 91L, 108L, 109L, 138L, 114L, 88L, 33L, 2L,
4L, 9L, 61L, 71L, 77L, 78L, 83L, 43L, 38L, 8L, 5L), V14 = c(53L,
60L, 43L, 49L, 104L, 128L, 72L, 44L, 6L, 8L, 10L, 24L, 35L,
27L, 33L, 37L, 31L, 24L, 10L, 5L), V15 = c(13L, 16L, 11L,
27L, 62L, 78L, 73L, 30L, 8L, 7L, 31L, 66L, 66L, 33L, 13L,
27L, 16L, 18L, 12L, 7L), V16 = c(11L, 12L, 7L, 3L, 16L, 35L,
45L, 13L, 5L, 7L, 22L, 74L, 73L, 31L, 16L, 43L, 35L, 14L,
15L, 8L), V17 = c(15L, 16L, 7L, 8L, 1L, 5L, 15L, 13L, 31L,
33L, 22L, 34L, 38L, 17L, 18L, 41L, 39L, 26L, 19L, 12L), V18 = c(9L,
15L, 7L, 2L, 2L, 5L, 5L, 25L, 50L, 55L, 35L, 25L, 14L, 8L,
18L, 44L, 36L, 36L, 19L, 0L), V19 = c(15L, 16L, 4L, 6L, 4L,
6L, 22L, 45L, 59L, 48L, 56L, 58L, 52L, 30L, 22L, 46L, 41L,
50L, 23L, 7L), V20 = c(20L, 7L, 4L, 2L, 6L, 14L, 40L, 55L,
74L, 60L, 69L, 74L, 60L, 56L, 38L, 45L, 67L, 39L, 25L, 11L
)), row.names = c(NA, 20L), class = "data.frame")
Is there a way to create this image in Rstudio?
I would like to generate a colour gradient plot from a df in R.
The df has 2 column, the first is a colour code and the second a number. So my plot only has one dimension in the X with a colour in the Y if that makes sense.
> dput(tail(df1, n=50))
structure(list(colours = c("#ADC07D", "#B5C272", "#C1C462", "#C2C460",
"#DCC93D", "#DDC93C", "#DDC93B", "#EACB28", "#EACA28", "#E9C723",
"#E7C31D", "#E7C21C", "#E7C019", "#E7C019", "#E5BD14", "#E5BC13",
"#E4B80D", "#E3B70C", "#E3B60A", "#E29F00", "#E29C00", "#E39700",
"#E48E00", "#E58900", "#E67E00", "#E77C00", "#E77700", "#E86B00",
"#EB5800", "#EB5600", "#EB5100", "#EE3B00", "#EE3800", "#EE3700",
"#EE3700", "#EF2E00", "#EF2A00", "#F02600", "#F11E00", "#C74024",
"#B14830", "#91503F", "#90503F", "#90503F", "#90503F", "#90503F",
"#90503F", "#90503F", "#90503F", "#90503F"), `V(network)$Forage` = c(0.362260261,
0.380421546, 0.405517922, 0.407835536, 0.46340053, 0.466050869,
0.466896832, 0.503383988, 0.506171832, 0.532890572, 0.566618979,
0.575902496, 0.594105734, 0.594567821, 0.622845671, 0.628271573,
0.664540722, 0.669849631, 0.679252365, 0.768537524, 0.774211483,
0.782423082, 0.79637798, 0.805285302, 0.824000365, 0.826130001,
0.835771962, 0.854854452, 0.886121785, 0.889545423, 0.898957372,
0.935814146, 0.939427578, 0.941018492, 0.941519951, 0.957215867,
0.963820732, 0.969986584, 0.983963985, 0.994455535, 0.996758715,
0.999923838, 0.999999791, 1, 1, 1, 1, 1, 1, 1)), row.names = c(19L,
115L, 37L, 46L, 11L, 14L, 124L, 42L, 49L, 70L, 118L, 13L, 4L,
116L, 17L, 71L, 95L, 22L, 113L, 43L, 114L, 122L, 48L, 102L, 35L,
36L, 9L, 40L, 44L, 119L, 25L, 26L, 38L, 33L, 41L, 106L, 96L,
45L, 1L, 101L, 39L, 99L, 98L, 3L, 18L, 27L, 29L, 34L, 97L, 100L
), class = "data.frame")
So far I am able to generate what I want but it looks ugly
> image(as.matrix(df1$`V(network)$Forage`), col = df1$colours)
So I was wondering if there are other cleaner ways to do this.
I am looking to color my points on my scatter plot by the hexcode assigned to each observation in an adjacent column in my data frame. I have tried this code:
ggplot(Data, aes(x = Y, y = X)) +
geom_point(aes(fill = hexcode, color = hexcode), alpha = 1)
Which yields this plot:
The plotted points are not the correct colors. For example, #002244 is a dark blue, but on the plot it's showing up as orange. Also, I'm not sure why the legend is showing up. What am I doing wrong here? Thanks in advance for any help!
Data:
structure(list(X = c(17L, 26L, 33L, 58L, 44L, 6L, 82L, 37L, 81L,
35L, 20L, 52L, 68L, 32L, 83L, 41L, 80L, 70L, 65L, 40L, 11L, 27L,
16L, 14L, 10L, 77L, 22L, 90L, 42L, 57L, 85L, 71L, 2L, 69L, 18L,
67L, 9L, 66L, 21L, 43L, 30L, 73L, 87L, 89L, 29L, 19L, 93L, 60L,
75L, 79L, 3L, 1L, 53L, 48L, 61L, 78L, 84L, 50L, 54L, 31L, 56L,
4L, 96L, 76L, 47L, 91L, 5L, 8L, 28L, 13L, 12L, 95L, 7L, 55L,
74L, 46L, 94L, 45L, 36L, 23L, 51L, 62L, 15L, 64L, 34L, 92L, 39L,
59L, 49L, 88L, 86L, 25L, 72L, 63L, 24L, 38L), Y = c(12L, 36L,
57L, 47L, 22L, 84L, 49L, 92L, 9L, 60L, 77L, 7L, 52L, 75L, 82L,
43L, 50L, 33L, 41L, 39L, 25L, 44L, 42L, 35L, 23L, 30L, 91L, 10L,
29L, 15L, 59L, 17L, 71L, 69L, 64L, 21L, 56L, 5L, 83L, 70L, 40L,
76L, 61L, 67L, 18L, 90L, 28L, 51L, 89L, 85L, 19L, 48L, 14L, 34L,
86L, 87L, 78L, 63L, 80L, 93L, 32L, 54L, 81L, 95L, 8L, 24L, 79L,
27L, 4L, 53L, 11L, 45L, 68L, 74L, 1L, 94L, 37L, 88L, 13L, 46L,
66L, 2L, 72L, 96L, 55L, 20L, 26L, 3L, 58L, 16L, 6L, 38L, 73L,
31L, 62L, 65L), hexcode = c("#0b2265", "#4f2683", "#9f8958",
"#004953", "#002244", "#002244", "#a71930", "#03202f", "#000000",
"#aa0000", "#d50a0a", "#241773", "#002c5f", "#00338d", "#fb4f14",
"#000000", "#008e97", "#000000", "#002244", "#002244", "#002244",
"#0085ca", "#e31837", "#002244", "#773141", "#97233f", "#203731",
"#005a8b", "#0b162a", "#203731", "#a5acaf", "#002244", "#0b162a",
"#203731", "#e31837", "#000000", "#002244", "#fb4f14", "#203731",
"#004953", "#0085ca", "#002244", "#a71930", "#00338d", "#773141",
"#241773", "#4f2683", "#008e97", "#000000", "#002244", "#002244",
"#002c5f", "#005a8b", "#97233f", "#d50a0a", "#002244", "#aa0000",
"#0b2265", "#002244", "#000000", "#002244", "#a5acaf", "#9f8958",
"#03202f", "#03202f", "#e31837", "#008e97", "#fb4f14", "#002c5f",
"#a71930", "#002244", "#773141", "#203731", "#0b162a", "#004953",
"#a5acaf", "#002244", "#203731", "#241773", "#00338d", "#0085ca",
"#000000", "#005a8b", "#4f2683", "#9f8958", "#aa0000", "#d50a0a",
"#000000", "#97233f", "#002244", "#002244", "#002244", "#0b2265",
"#000000", "#002244", "#002244")), row.names = c(NA, -96L), class = "data.frame")
The following two approaches will work
library(ggplot2)
ggplot(Data, aes(x = Y, y = X)) +
geom_point(alpha = 1, color = Data$hexcode)
ggplot(Data, aes(x = Y, y = X, color = hexcode)) +
geom_point(alpha = 1) +
scale_color_identity()
I have this sample:
x=c(92L, 9L, 38L, 43L, 74L, 16L, 75L, 55L, 39L, 77L, 76L, 52L,
100L, 85L, 62L, 60L, 49L, 28L, 6L, 27L, 63L, 22L, 23L, 99L, 61L,
25L, 19L, 48L, 91L, 57L, 97L, 84L, 31L, 87L, 1L, 21L, 30L, 41L,
13L, 72L, 68L, 95L, 47L, 11L, 24L, 58L, 18L, 67L, 33L, 8L, 50L,
4L, 40L, 12L, 73L, 78L, 86L, 69L, 44L, 83L, 94L, 65L, 37L, 70L,
54L, 46L, 15L, 53L, 89L, 98L, 90L, 3L, 14L, 17L, 42L, 45L, 79L,
20L, 32L, 34L, 64L, 88L, 81L, 96L, 59L, 71L, 56L, 26L, 51L, 29L,
80L, 7L, 36L, 93L, 82L, 35L, 5L, 2L, 10L, 66L)
I want to calculate this probability: P(x) > Mean(x) + 3 assuming that data have normal distribution.
So I do this: mean(x) = 50.5 ; sd(x)=29.01
I generate the density distribution and calculate my probability, which now is:
P(x) > 53.5
pnorm(53.5, mean=mean(x), sd=sd(x), lower.tail=FALSE)
If I want calculating using Standard Distribution:
P(x)>(53.5) = P(z=(x-mean(x)/sd(x))) > ((53.5 - 50.5)/29.01) = P(z)>(3/29.01)
pnorm(3/29.01149, mean=0, sd=1, lower.tail=FALSE)
But when I want to use the T-Student Distribution, how can I proceed?
It is more legitimate to use t distribution here, as standard error is estimated from data.
pt(3 / sd(x), df = length(x) - 1, lower.tail = FALSE)
# [1] 0.4589245
We have length(x) number of data, but also estimate 1 parameter (standard error), so the degree of freedom for t-distribution is length(x) - 1.
There is not much difference compared with using normal distribution, though, given that length(x) is 100 (which is large enough):
pnorm(3 / sd(x), lower.tail = FALSE)
# [1] 0.4588199
From an hclust object, how can I extract only selected observations (to_plot below) and plot a dendrogram from these selected observations? This subset of observations I want to plot as a dendrogram, will not correspond to the tree structure of the hclust object, so I can't extract branches from the dendrogram.
NB. I do not wish to cluster or calculate the distance matrix using the subset of selected observations
Data
1/ hclust object
structure(list(merge = structure(c(-31L, -62L, -46L, -37L, -55L,
-47L, -75L, -57L, -6L, -2L, -45L, -99L, -51L, -12L, -30L, -4L,
3L, -53L, -61L, -27L, -56L, -83L, -38L, -101L, -69L, -11L, -14L,
-21L, -34L, -48L, -82L, -92L, -15L, -7L, -35L, -65L, -105L, -52L,
-40L, -64L, -23L, -94L, -98L, -1L, -25L, -8L, 8L, -41L, -3L,
-33L, -108L, 23L, -58L, -20L, -5L, -93L, 30L, -68L, -49L, -28L,
-17L, 9L, -32L, 35L, -95L, -67L, 26L, -107L, 17L, -19L, -74L,
-63L, 37L, 20L, -84L, 50L, -10L, -13L, 49L, 34L, 39L, 60L, -16L,
63L, 44L, 29L, 10L, -24L, 75L, 73L, 47L, 61L, 57L, 18L, 66L,
43L, 80L, 83L, -78L, -71L, 90L, 93L, 84L, 94L, 102L, 98L, 100L,
87L, 106L, 108L, -97L, 1L, -100L, -43L, -59L, -106L, 4L, -90L,
5L, 2L, -87L, -103L, -86L, -54L, -89L, -42L, 11L, 13L, 12L, -77L,
7L, 14L, 6L, -110L, 22L, -60L, -44L, -91L, -111L, -102L, -88L,
-104L, -50L, -22L, -36L, -79L, 28L, 24L, -66L, 15L, -29L, 25L,
32L, -109L, -39L, 45L, 42L, -96L, 16L, 33L, 19L, 40L, 27L, 31L,
-9L, 41L, 46L, -80L, -81L, -70L, -26L, 21L, -73L, 48L, 38L, 36L,
53L, 56L, 51L, -72L, -85L, -76L, 52L, 58L, 71L, 59L, 64L, -18L,
68L, 54L, 55L, 65L, 70L, 79L, 72L, 74L, 69L, 78L, 77L, 76L, 62L,
81L, 82L, 67L, 86L, 85L, 95L, 89L, 92L, 88L, 91L, 97L, 96L, 99L,
103L, 104L, 105L, 101L, 107L, 109L), .Dim = c(110L, 2L)), height = c(0,
0.188350217744365, 0.247401000321179, 0.249231910045009, 0.261866742195707,
0.377720124194474, 0.378461142310176, 0.527418629683044, 0.636480697844057,
0.70489556723743, 0.799857388088743, 0.895267189098051, 0.940604516439695,
1, 1, 1.25645841742159, 1.47637080579504, 1.49661353166068, 1.60280854934758,
1.64538982117314, 1.65011076915935, 1.66666666666667, 1.8661900064933,
1.91530600787293, 1.95979930296005, 2, 2, 2, 2, 2, 2, 2, 2.06532735656427,
2.32083831336158, 2.44558763136158, 2.48004395957454, 2.65074432837975,
2.69489799737569, 2.71536352494182, 2.75337988132381, 2.87695888696678,
2.89093184314013, 2.91669905927746, 3, 3.03504556878056, 3.42442760079317,
3.50924315636259, 3.54456009196554, 3.58118052752614, 3.80716728885077,
4.26149878117642, 4.63502500606874, 4.66666666666667, 4.66666666666667,
4.76912295317528, 4.90702353976517, 4.92512811564295, 5, 5.15887380396718,
5.20227981903921, 5.39890417564938, 5.71781232947912, 5.94961450567626,
6.17569787723772, 6.21000141305934, 6.47150288200403, 6.48552894195153,
6.61209720286382, 7.27379923250834, 7.65301130607984, 7.74920607244712,
7.8800745368487, 8.17570945188961, 8.75305138718179, 8.87870428752716,
9.36365055557565, 9.68439736325147, 10, 10.121604958431, 10.2845151775143,
10.7517404855684, 10.8165382868783, 11.4489962313067, 11.5939995243571,
12.8179231278111, 12.3055509866599, 14.1589468158871, 14.6988252554622,
14.7792803434488, 15.276874084329, 16.0150635281041, 17.9467649484583,
21.2687065983256, 21.3844895922187, 24.196270007066, 25.3163200486723,
34.1772731084418, 37.4454933955768, 42.6291683810462, 45.1916356921658,
52.531016897072, 55.6590891226214, 61.0699226448619, 73.7706208334886,
98.5310119994231, 148.608243702477, 150.474954574704, 187.419419688973,
241.610436881262, 487.90491231433), order = c(2L, 62L, 31L, 97L,
46L, 100L, 45L, 87L, 108L, 61L, 99L, 103L, 105L, 21L, 91L, 38L,
47L, 106L, 64L, 30L, 89L, 33L, 15L, 50L, 49L, 81L, 57L, 90L,
94L, 69L, 83L, 12L, 54L, 6L, 55L, 59L, 56L, 75L, 37L, 43L, 16L,
19L, 72L, 84L, 74L, 85L, 10L, 35L, 36L, 41L, 96L, 53L, 51L, 86L,
11L, 60L, 58L, 14L, 44L, 78L, 17L, 26L, 40L, 66L, 5L, 9L, 71L,
24L, 13L, 18L, 48L, 102L, 8L, 25L, 39L, 28L, 70L, 95L, 52L, 101L,
110L, 7L, 22L, 20L, 82L, 88L, 67L, 65L, 79L, 34L, 111L, 27L,
77L, 68L, 80L, 32L, 73L, 3L, 4L, 42L, 107L, 93L, 23L, 29L, 98L,
92L, 104L, 1L, 109L, 63L, 76L), labels = c("DX_100203", "DX_100208",
"DX_30528", "DX_100159", "DX_100211", "DX_100215", "DX_100246", "DX_100253",
"DX_100271", "DX_100212", "DX_100035", "DX_100164", "DX_100249", "DX_100036",
"DX_100165", "DX_100221", "DX_100254", "DX_100262", "DX_100274", "DX_100046",
"DX_100171", "DX_100230", "DX_100255", "DX_100275", "DX_100180", "DX_100269",
"DX_100278", "DX_100161", "DX_100229", "DX_100238", "DX_100093", "DX_100191",
"DX_100241", "DX_100237", "DX_100268", "DX_30515", "DX_90862", "DX_30529",
"DX_100073", "DX_90264", "DX_90221", "DX_30550", "DX_90885", "DX_100028",
"DX_100049", "DX_90257", "DX_90215", "DX_30527", "DX_30526", "DX_90892",
"DX_100051", "DX_90333", "DX_90286", "DX_90217", "DX_90252", "DX_90232",
"DX_30573", "DX_100214", "DX_90769", "DX_90907", "DX_100037", "DX_100054",
"DX_30568", "DX_90230", "DX_90280", "DX_90779", "DX_90959", "DX_100187",
"DX_100081", "DX_90310", "DX_90782", "DX_100023", "DX_90994", "DX_100042",
"DX_90304", "DX_100152", "DX_90272", "DX_90861", "DX_100043", "DX_100068",
"DX_30571", "DX_100085", "DX_90312", "DX_30590", "DX_90413", "DX_30561",
"DX_30548", "DX_90296", "DX_30558", "DX_90243", "DX_90293", "DX_90365",
"DX_30584", "DX_90274", "DX_90332", "DX_30583", "DX_30575", "DX_30523",
"DX_30578", "DX_90377", "DX_90297", "DX_30593", "DX_30555", "DX_30549",
"DX_90292", "DX_30565", "DX_30512", "DX_90285", "DX_90231", "DX_90209",
"DX_30570"), method = "ward", call = hclust(d = distance, method = method.hclust),
dist.method = "maximum"), .Names = c("merge", "height", "order",
"labels", "method", "call", "dist.method"), class = "hclust")
2/ subset of observations to extract for plotting as a dendrogram
to_plot <- c("DX_90264", "DX_90221", "DX_30550", "DX_90885", "DX_100028", "DX_100159",
"DX_100049", "DX_90257", "DX_90215", "DX_30527", "DX_30526", "DX_90892",
"DX_100051", "DX_90333", "DX_90286", "DX_90217", "DX_90252", "DX_90232",
"DX_30573", "DX_100214", "DX_90769", "DX_90907", "DX_100037", "DX_100054", "DX_30565")
Based on the comment of #RomanLuštrik I would suggest something like this:
hc <- hclust(dist(USArrests), "ave")
## select some observations to plot
set.seed(1)
toPlot <- sample(rownames(USArrests), size=20)
## use rownames as labels
labels <- rownames(USArrests)
## clear labels not present in toPlot
labels[ !(labels %in% toPlot) ] <- ""
plot(hc, labels=labels)