Massachusetts Institute of Technology


July 5, 2020

I have experienced a few explosions here and there. Yes, it’s me not reading the docs. But it’s also me, assuming that verbs mean one thing and not another. Let’s do some unique operations in different languages.

The MATLAB way

>> unique([3, 3, 3, 90, 10])

ans =

3 10 90

The Python way

>>> import numpy as np
>>> np.unique([3, 3, 3, 90, 10])
array([ 3, 10, 90])

The R way

[1]  3 90 10

This is what I would expect. I want the unique values, without the sorting. If I wanted to sort, I would do:

[1]  3 10 90

Maybe this is just me and R is the odd (read intuitive) ball here, but 🤷…



BibTeX citation:
  author = {Andina, Matias},
  title = {Unique},
  date = {2020-07-05},
  url = {https://matiasandina.com/posts/2020-07-05-Unique},
  langid = {en}
For attribution, please cite this work as:
Andina, Matias. 2020. “Unique.” July 5, 2020. https://matiasandina.com/posts/2020-07-05-Unique.

Enjoy my creations?

I'm so glad you're here. As you know, I create a blend of fiction, non-fiction, open-source software, and generative art - all of which I provide for free.

Creating quality content takes a lot of time and effort, and your support would mean the world to me. It would empower me to continue sharing my work and keep everything accessible for everyone.

How can you support my work?

There easy ways to contribute. You can buy me coffee, become a patron on Patreon, or make a donation via PayPal. Every bit helps to keep the creative juices flowing.

Become a Patron!

Share the Love

Not in a position to contribute financially? No problem! Sharing my work with others also goes a long way. You can use the following links to share this post on your social media.

Affiliate Links

Please note that some of the links above might be affiliate links. At no additional cost to you, I will earn a commission if you decide to make a purchase.

© CC-By Matias Andina, 2023 | This page is built with ❤️ and Quarto.