# Calculating just a single row of dissimilarity/distance matrix

4 messages
Open this post in threaded view
|

## Calculating just a single row of dissimilarity/distance matrix

 I have a data-frame with 30k rows and 10 features. I would like to calculate distance matrix like below; gower_dist <- daisy(data-frame, metric = "gower"), This function returns whole dissimilarity matrix. I want to get just the first row. (Just distances of the first element in data-frame). How can I do it? Do you have an idea? Regards         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Calculating just a single row of dissimilarity/distance matrix

 > first_row_dist <- as.numeric(gower_dist)[1:(attr(gower_dist,"Size")-1)] will give you the distances of the first row from the subsequent rows. HTH, Eric On Fri, Oct 26, 2018 at 4:07 PM Aerenbkts bkts <[hidden email]> wrote: > I have a data-frame with 30k rows and 10 features. I would like to > calculate distance matrix like below; > > gower_dist <- daisy(data-frame, metric = "gower"), > > > This function returns whole dissimilarity matrix. I want to get just > the first row. > (Just distances of the first element in data-frame). How can I do it? > Do you have an idea? > > > Regards > >         [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.