I have a dataframe which has categorical and numeric variables. I want to cluster this data using gower distance and get cluster values as a vector as in kmeans function. How can i achieve that?
Clustering using gower distance in R
7.7k views Asked by cuneyttyler At
2
There are 2 answers
0
Mehmet Yildirim
On
You can use kproto() function from clustMixType if you don't want to insist on using Gower distance. The distance measure in kproto is similar to Gower distance except that kproto uses Euclidean distance to measure dissimilarity between numerical variables; however, Gower distance normalizes each variable (divides the distance between two observations by the range of that variable). The code is pretty simple.
kproto_clustering <- kproto(df, k) # k is number of cluster
clusters <- kproto_clustering$cluster
Related Questions in R
- How to make an R Shiny app with big data?
- How do I keep only specific rows based on whether a column has a specific value?
- Likert scale study - ordinal regression model
- Extract a table/matrix from R into Excel with same colors and stle
- How can I solve non-conformable arguments in R netmeta::discomb (Error in B.matrix %*% C.matrix)?
- Can raw means and estimated marginal means be the same ? And when?
- Understanding accumulate function when .dir is set to "backwards"
- Error in if (nrow(peaks) > 0) { : argument is of length zero Calls: CopywriteR ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution ha
- How to increase quality of mathjax output?
- Convert the time intervals to equal hours and fill in the value column
- How to run an R function getpoints() from IPDfromKM package in an R shiny app which in R pops up a plot that utilizes clicks to capture coordinates?
- Replace NA in list of dfs in certain columns and under certain conditions
- R and text on Cyrillic
- The ts() function in R is returning the correct start and frequency but not end value which is 1 and not 179
- TROUBLING with the "DROP_NA" Function
Related Questions in CLUSTER-ANALYSIS
- Cluster Analysis after a process
- Threshold scaling along a straight line
- create a bubble plot (or something similar) from cluster analysis in R
- Project idea about clustering and sentences similarity
- Mahalanobis distance computation in Python
- Adding a Bubble Plot as a Complex Heatmap Annotation
- Clustering Medium length (100bp) DNA Sequences
- Indicating the same clusters by colour between two Igraph plots using k mean clustering
- how to specify the maximum number of clusters for the STC algorithm in Solr admin console?
- Text clustering based on “stance” rather than the distribution of embeddings as the basis for clustering
- R ComplexHeatmap cannot reproduce exact row orders when apply row clusters to new matrix
- Principal Component Analysis and Clustering - Better Discrimination between Classes
- Recreating a spectral analysis and cluster graph example from RPUBS using K-means algorithm
- flowMatch metaclustering throws unexpteced error
- How to change 2D k-means algorithm to 2D EM-algorithm?
Related Questions in CATEGORICAL-DATA
- Pandas categorical columns to factorize tables
- Plotting categorical covariate against occupancy using unmarked package
- writing an r function so it can recieve a list of names to run
- Package for category overlines on scatterplot in ggplot
- Dealing with QY data: How to define levels of QY factors
- Excluding within-category interactions with step_interact()
- Return value from multiple columns if the column is the most recent previous year
- Upsampling categorical variable in time series data in R
- Simple Linear Regression between numeric and categorical variables
- How to make a line and dot chart to represent frequencies of categorical variables?
- Identify a Boolean in large datasets in Python
- Error while creating a proportions table in R: Error in table(st2.affect) : attempt to make a table with \>= 2^31 elements
- Does catboost have a maximum number of categories?
- ValueError: When categorical type is supplied, DMatrix parameter `enable_categorical` must be set to `True` , XGBoost Regression
- Categorical features with many unique values in a machine learning model
Related Questions in MIXED-TYPE
- Dynamically assign property of object with mixed-type properties in TypeScript
- Pandas: Drop all string components in a mixed typed series with integers and strings
- Swift Decodable for a list or items of mixed types
- How to access different attributes of different implementation of the same interface
- Migrating python2 mixed-type np.array operations to python3
- How to create mixed type data in pandas
- Converting Floats to String in Mixed Type DF Column Uses Scientific Notation
- Check if value is equal to 0 for mixed type column (with timedelta and floats)
- How to decide best number of clusters for kamila clustering with R?
- Clustering a mixed data set in R
- Clustering using gower distance in R
- How can mixed data types (int, float, char, etc) be stored in an array?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
You can use the vegan package to generate your gower matrix, and then create your clusters using the cluster package.
Then you can feed that matrix into the PAM function. The example below will use the gower distance to generate 5 clusters
You can then get your cluster information from