{"id":8129,"date":"2018-11-04T09:28:59","date_gmt":"2018-11-04T07:28:59","guid":{"rendered":"https:\/\/www.datanovia.com\/en\/?p=8129"},"modified":"2019-12-25T11:28:00","modified_gmt":"2019-12-25T09:28:00","slug":"clustering-example-4-steps-you-should-know","status":"publish","type":"post","link":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/","title":{"rendered":"Clustering Example: 4 Steps You Should Know"},"content":{"rendered":"<div id=\"rdoc\">\n<p>This article describes <em>k-means<\/em> <strong>clustering example<\/strong> and provide a step-by-step guide summarizing the different steps to follow for conducting a cluster analysis on a real data set using R software.<\/p>\n<p>We\u2019ll use mainly two R packages:<\/p>\n<ul>\n<li>cluster: for cluster analyses and<\/li>\n<li>factoextra: for the visualization of the analysis results.<\/li>\n<\/ul>\n<p>Install these packages, as follow:<\/p>\n<pre class=\"r\"><code>install.packages(c(\"cluster\", \"factoextra\"))<\/code><\/pre>\n<p>A rigorous cluster analysis can be conducted in 3 steps mentioned below:<\/p>\n<div class=\"block\">\n<ol style=\"list-style-type: decimal;\">\n<li>Data preparation<\/li>\n<li><a href=\"\/?p=8060\">Assessing clustering tendency (i.e., the clusterability of the data)<\/a><\/li>\n<li><a href=\"\/?p=8062\">Defining the optimal number of clusters<\/a><\/li>\n<li><a href=\"\/?p=7673\">Computing partitioning cluster analyses (e.g.: k-means, pam)<\/a> or <a href=\"\/?p=7685\">hierarchical clustering<\/a><\/li>\n<li><a href=\"http:\/\/www.sthda.com\/english\/articles\/29-cluster-validation-essentials\/97-cluster-validation-statistics-must-know-methods\/\">Validating clustering analyses: silhouette plot<\/a><\/li>\n<\/ol>\n<\/div>\n<p>Here, we provide quick R scripts to perform all these steps.<\/p>\n<p>Contents:<\/p>\n<div id=\"TOC\">\n<ul>\n<li><a href=\"#data-preparation\">Data preparation<\/a><\/li>\n<li><a href=\"#assessing-the-clusterability\">Assessing the clusterability<\/a><\/li>\n<li><a href=\"#estimate-the-number-of-clusters-in-the-data\">Estimate the number of clusters in the data<\/a><\/li>\n<li><a href=\"#compute-k-means-clustering\">Compute k-means clustering<\/a><\/li>\n<li><a href=\"#cluster-validation-statistics-inspect-cluster-silhouette-plot\">Cluster validation statistics: Inspect cluster silhouette plot<\/a><\/li>\n<li><a href=\"#eclust-enhanced-clustering-analysis\">eclust(): Enhanced clustering analysis<\/a>\n<ul>\n<li><a href=\"#k-means-clustering-using-eclust\">K-means clustering using eclust()<\/a><\/li>\n<li><a href=\"#hierachical-clustering-using-eclust\">Hierachical clustering using eclust()<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<div class='dt-sc-hr-invisible-medium  '><\/div>\n<div class='dt-sc-ico-content type1'><div class='custom-icon' ><a href='https:\/\/www.datanovia.com\/en\/product\/practical-guide-to-cluster-analysis-in-r\/' target='_blank'><span class='fa fa-book'><\/span><\/a><\/div><h4><a href='https:\/\/www.datanovia.com\/en\/product\/practical-guide-to-cluster-analysis-in-r\/' target='_blank'> Related Book <\/a><\/h4>Practical Guide to Cluster Analysis in R<\/div>\n<div class='dt-sc-hr-invisible-medium  '><\/div>\n<div id=\"data-preparation\" class=\"section level2\">\n<h2>Data preparation<\/h2>\n<p>We\u2019ll use the demo data set USArrests. We start by standardizing the data using the <em>scale<\/em>() function:<\/p>\n<pre class=\"r\"><code># Load the data set\r\ndata(USArrests)\r\n# Standardize\r\ndf &lt;- scale(USArrests)<\/code><\/pre>\n<\/div>\n<div id=\"assessing-the-clusterability\" class=\"section level2\">\n<h2>Assessing the clusterability<\/h2>\n<p>The function <em>get_clust_tendency<\/em>() [factoextra package] can be used. It computes the <a href=\"\/?p=8060#statistical-methods\"><em>Hopkins statistic<\/em><\/a> and provides a visual approach.<\/p>\n<pre class=\"r\"><code>library(\"factoextra\")\r\nres &lt;- get_clust_tendency(df, 40, graph = TRUE)\r\n# Hopskin statistic\r\nres$hopkins_stat<\/code><\/pre>\n<pre><code>## [1] 0.656<\/code><\/pre>\n<pre class=\"r\"><code># Visualize the dissimilarity matrix\r\nprint(res$plot)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-cluster-tendency-1.png\" width=\"432\" \/><\/p>\n<div class=\"success\">\n<p>The value of the <a href=\"\/?p=8060#statistical-methods\">Hopkins statistic<\/a> is significantly &lt; 0.5, indicating that the data is highly clusterable. Additionally, It can be seen that the ordered dissimilarity image contains patterns (i.e., clusters).<\/p>\n<\/div>\n<\/div>\n<div id=\"estimate-the-number-of-clusters-in-the-data\" class=\"section level2\">\n<h2>Estimate the number of clusters in the data<\/h2>\n<p>As k-means clustering requires to specify the number of clusters to generate, we\u2019ll use the function clusGap() [cluster package] to compute <a href=\"\/?p=8062#gap-statistic-method\">gap statistics<\/a> for estimating the optimal number of clusters . The function <em>fviz_gap_stat<\/em>() [factoextra] is used to visualize the gap statistic plot.<\/p>\n<pre class=\"r\"><code>library(\"cluster\")\r\nset.seed(123)\r\n# Compute the gap statistic\r\ngap_stat &lt;- clusGap(df, FUN = kmeans, nstart = 25, \r\n                    K.max = 10, B = 100) \r\n# Plot the result\r\nlibrary(factoextra)\r\nfviz_gap_stat(gap_stat)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-number-of-clusters-gap-statistic-1.png\" width=\"518.4\" \/><\/p>\n<div class=\"success\">\n<p>The gap statistic suggests a 4 cluster solutions.<\/p>\n<\/div>\n<div class=\"notice\">\n<p>It\u2019s also possible to use the function <a href=\"\/?p=8062#nbclust-function-30-indices-for-choosing-the-best-number-of-clusters\"><strong>NbClust()<\/strong><\/a> [in <strong>NbClust<\/strong>] package.<\/p>\n<\/div>\n<\/div>\n<div id=\"compute-k-means-clustering\" class=\"section level2\">\n<h2>Compute k-means clustering<\/h2>\n<p><a href=\"\/?p=7674\">K-means clustering<\/a> with k = 4:<\/p>\n<pre class=\"r\"><code># Compute k-means\r\nset.seed(123)\r\nkm.res &lt;- kmeans(df, 4, nstart = 25)\r\nhead(km.res$cluster, 20)<\/code><\/pre>\n<pre><code>##     Alabama      Alaska     Arizona    Arkansas  California    Colorado \r\n##           4           3           3           4           3           3 \r\n## Connecticut    Delaware     Florida     Georgia      Hawaii       Idaho \r\n##           2           2           3           4           2           1 \r\n##    Illinois     Indiana        Iowa      Kansas    Kentucky   Louisiana \r\n##           3           2           1           2           1           4 \r\n##       Maine    Maryland \r\n##           1           3<\/code><\/pre>\n<pre class=\"r\"><code># Visualize clusters using factoextra\r\nfviz_cluster(km.res, USArrests)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-k-means-factoextra-1.png\" width=\"518.4\" \/><\/p>\n<\/div>\n<div id=\"cluster-validation-statistics-inspect-cluster-silhouette-plot\" class=\"section level2\">\n<h2>Cluster validation statistics: Inspect cluster silhouette plot<\/h2>\n<p>Recall that the <a href=\"\/?p=8063#silhouette-coefficient\">silhouette measures<\/a> (<span class=\"math inline\">\\(S_i\\)<\/span>) how similar an object <span class=\"math inline\">\\(i\\)<\/span> is to the the other objects in its own cluster versus those in the neighbor cluster. <span class=\"math inline\">\\(S_i\\)<\/span> values range from 1 to - 1:<\/p>\n<ul>\n<li>A value of <span class=\"math inline\">\\(S_i\\)<\/span> close to 1 indicates that the object is well clustered. In the other words, the object <span class=\"math inline\">\\(i\\)<\/span> is similar to the other objects in its group.<\/li>\n<li>A value of <span class=\"math inline\">\\(S_i\\)<\/span> close to -1 indicates that the object is poorly clustered, and that assignment to some other cluster would probably improve the overall results.<\/li>\n<\/ul>\n<pre class=\"r\"><code>sil &lt;- silhouette(km.res$cluster, dist(df))\r\nrownames(sil) &lt;- rownames(USArrests)\r\nhead(sil[, 1:3])<\/code><\/pre>\n<pre><code>##            cluster neighbor sil_width\r\n## Alabama          4        3    0.4858\r\n## Alaska           3        4    0.0583\r\n## Arizona          3        2    0.4155\r\n## Arkansas         4        2    0.1187\r\n## California       3        2    0.4356\r\n## Colorado         3        2    0.3265<\/code><\/pre>\n<pre class=\"r\"><code>fviz_silhouette(sil)<\/code><\/pre>\n<pre><code>##   cluster size ave.sil.width\r\n## 1       1   13          0.37\r\n## 2       2   16          0.34\r\n## 3       3   13          0.27\r\n## 4       4    8          0.39<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-silhouette-plot-1.png\" width=\"518.4\" \/><\/p>\n<p>It can be seen that there are some samples which have negative silhouette values. Some natural questions are :<\/p>\n<p><span class=\"question\">Which samples are these? To what cluster are they closer?<\/span><\/p>\n<p>This can be determined from the output of the function <em>silhouette<\/em>() as follow:<\/p>\n<pre class=\"r\"><code>neg_sil_index &lt;- which(sil[, \"sil_width\"] &lt; 0)\r\nsil[neg_sil_index, , drop = FALSE]<\/code><\/pre>\n<pre><code>##          cluster neighbor sil_width\r\n## Missouri       3        2   -0.0732<\/code><\/pre>\n<\/div>\n<div id=\"eclust-enhanced-clustering-analysis\" class=\"section level2\">\n<h2>eclust(): Enhanced clustering analysis<\/h2>\n<p>The function <a href=\"https:\/\/www.datanovia.com\/en\/blog\/cluster-analysis-in-r-simplified-and-enhanced\/\">eclust()<\/a>[factoextra package] provides several advantages compared to the standard packages used for clustering analysis:<\/p>\n<ul>\n<li>It simplifies the workflow of clustering analysis<\/li>\n<li>It can be used to compute hierarchical clustering and partitioning clustering in a single line function call<\/li>\n<li>The function eclust() computes automatically the gap statistic for estimating the right number of clusters.<\/li>\n<li>It automatically provides silhouette information<\/li>\n<li>It draws beautiful graphs using ggplot2<\/li>\n<\/ul>\n<div id=\"k-means-clustering-using-eclust\" class=\"section level3\">\n<h3>K-means clustering using eclust()<\/h3>\n<pre class=\"r\"><code># Compute k-means\r\nres.km &lt;- eclust(df, \"kmeans\", nstart = 25)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-eclust-k-means-1.png\" width=\"518.4\" \/><\/p>\n<pre class=\"r\"><code># Gap statistic plot\r\nfviz_gap_stat(res.km$gap_stat)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-eclust-k-means-2.png\" width=\"518.4\" \/><\/p>\n<pre class=\"r\"><code># Silhouette plot\r\nfviz_silhouette(res.km)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-eclust-k-means-3.png\" width=\"518.4\" \/><\/p>\n<\/div>\n<div id=\"hierachical-clustering-using-eclust\" class=\"section level3\">\n<h3>Hierachical clustering using eclust()<\/h3>\n<pre class=\"r\"><code> # Enhanced hierarchical clustering\r\nres.hc &lt;- eclust(df, \"hclust\") # compute hclust<\/code><\/pre>\n<pre><code>## Clustering k = 1,2,..., K.max (= 10): .. done\r\n## Bootstrapping, b = 1,2,..., B (= 100)  [one \".\" per sample]:\r\n## .................................................. 50 \r\n## .................................................. 100<\/code><\/pre>\n<pre class=\"r\"><code>fviz_dend(res.hc, rect = TRUE) # dendrogam<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/dn-tutorials\/cluster-analysis\/figures\/058-clustering-example-eclust-hierarchical-clustering-1.png\" width=\"518.4\" \/><\/p>\n<p>The R code below generates the silhouette plot and the scatter plot for hierarchical clustering.<\/p>\n<pre class=\"r\"><code>fviz_silhouette(res.hc) # silhouette plot\r\nfviz_cluster(res.hc) # scatter plot<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p><!--end rdoc--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes k-means clustering example and provide a step-by-step guide summarizing the different steps to follow for conducting a cluster analysis on a real data set using R software. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7908,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rating_form_position":"","rating_results_position":"","mr_structured_data_type":"","footnotes":""},"categories":[123],"tags":[],"class_list":["post-8129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cluster-analysis"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Clustering Example in R: 4 Crucial Steps You Should Know - Datanovia<\/title>\n<meta name=\"description\" content=\"We describe clustering example and provide a step-by-step guide summarizing the crucial steps for cluster analysis on a real data set using R software.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Clustering Example in R: 4 Crucial Steps You Should Know - Datanovia\" \/>\n<meta property=\"og:description\" content=\"We describe clustering example and provide a step-by-step guide summarizing the crucial steps for cluster analysis on a real data set using R software.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\" \/>\n<meta property=\"og:site_name\" content=\"Datanovia\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-04T07:28:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-25T09:28:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alboukadel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alboukadel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\"},\"author\":{\"name\":\"Alboukadel\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\"},\"headline\":\"Clustering Example: 4 Steps You Should Know\",\"datePublished\":\"2018-11-04T07:28:59+00:00\",\"dateModified\":\"2019-12-25T09:28:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\"},\"wordCount\":583,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg\",\"articleSection\":[\"Cluster Analysis\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\",\"name\":\"Clustering Example in R: 4 Crucial Steps You Should Know - Datanovia\",\"isPartOf\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg\",\"datePublished\":\"2018-11-04T07:28:59+00:00\",\"dateModified\":\"2019-12-25T09:28:00+00:00\",\"description\":\"We describe clustering example and provide a step-by-step guide summarizing the crucial steps for cluster analysis on a real data set using R software.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg\",\"width\":1024,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.datanovia.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Clustering Example: 4 Steps You Should Know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#website\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"name\":\"Datanovia\",\"description\":\"Data Mining and Statistics for Decision Support\",\"publisher\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.datanovia.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#organization\",\"name\":\"Datanovia\",\"url\":\"https:\/\/www.datanovia.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"contentUrl\":\"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png\",\"width\":98,\"height\":99,\"caption\":\"Datanovia\"},\"image\":{\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e\",\"name\":\"Alboukadel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g\",\"caption\":\"Alboukadel\"},\"url\":\"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Clustering Example in R: 4 Crucial Steps You Should Know - Datanovia","description":"We describe clustering example and provide a step-by-step guide summarizing the crucial steps for cluster analysis on a real data set using R software.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/","og_locale":"en_US","og_type":"article","og_title":"Clustering Example in R: 4 Crucial Steps You Should Know - Datanovia","og_description":"We describe clustering example and provide a step-by-step guide summarizing the crucial steps for cluster analysis on a real data set using R software.","og_url":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/","og_site_name":"Datanovia","article_published_time":"2018-11-04T07:28:59+00:00","article_modified_time":"2019-12-25T09:28:00+00:00","og_image":[{"width":1024,"height":512,"url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg","type":"image\/jpeg"}],"author":"Alboukadel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alboukadel","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#article","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/"},"author":{"name":"Alboukadel","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e"},"headline":"Clustering Example: 4 Steps You Should Know","datePublished":"2018-11-04T07:28:59+00:00","dateModified":"2019-12-25T09:28:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/"},"wordCount":583,"commentCount":5,"publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg","articleSection":["Cluster Analysis"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/","url":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/","name":"Clustering Example in R: 4 Crucial Steps You Should Know - Datanovia","isPartOf":{"@id":"https:\/\/www.datanovia.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg","datePublished":"2018-11-04T07:28:59+00:00","dateModified":"2019-12-25T09:28:00+00:00","description":"We describe clustering example and provide a step-by-step guide summarizing the crucial steps for cluster analysis on a real data set using R software.","breadcrumb":{"@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#primaryimage","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/10\/IMG_2051.jpg","width":1024,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.datanovia.com\/en\/blog\/clustering-example-4-steps-you-should-know\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.datanovia.com\/en\/"},{"@type":"ListItem","position":2,"name":"Clustering Example: 4 Steps You Should Know"}]},{"@type":"WebSite","@id":"https:\/\/www.datanovia.com\/en\/#website","url":"https:\/\/www.datanovia.com\/en\/","name":"Datanovia","description":"Data Mining and Statistics for Decision Support","publisher":{"@id":"https:\/\/www.datanovia.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanovia.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanovia.com\/en\/#organization","name":"Datanovia","url":"https:\/\/www.datanovia.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","contentUrl":"https:\/\/www.datanovia.com\/en\/wp-content\/uploads\/2018\/09\/datanovia-logo.png","width":98,"height":99,"caption":"Datanovia"},"image":{"@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/7767cf2bd5c91a1610c6eb53a0ff069e","name":"Alboukadel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanovia.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed3108646c5c7c3d188324ab972f96ad7d9975b41b94014d7f68257791be395a?s=96&d=mm&r=g","caption":"Alboukadel"},"url":"https:\/\/www.datanovia.com\/en\/blog\/author\/kassambara\/"}]}},"multi-rating":{"mr_rating_results":[]},"_links":{"self":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/8129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/comments?post=8129"}],"version-history":[{"count":1,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/8129\/revisions"}],"predecessor-version":[{"id":8130,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/posts\/8129\/revisions\/8130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media\/7908"}],"wp:attachment":[{"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/media?parent=8129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/categories?post=8129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datanovia.com\/en\/wp-json\/wp\/v2\/tags?post=8129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}