# Skipmissing no working in cor function

**URL:** https://discourse.julialang.org/t/skipmissing-no-working-in-cor-function/71293
**Category:** New to Julia
**Tags:** question
**Created:** [November 10, 2021, 11:01pm UTC](https://discourse.julialang.org/t/skipmissing-no-working-in-cor-function/71293 "2021-11-10T23:01:33Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [November 11, 2021, 12:24am UTC](https://discourse.julialang.org/t/skipmissing-no-working-in-cor-function/71293/3 "2021-11-11T00:24:13Z")

</div>

First, you are applying `skipmissing` too late.

But even if you were to correct it, `cor` wouldn’t work. This is a long-standing annoyance.

> [@aramirezreyes](#):
>
> `cor( skipmissing(df.Remates_arco), skipmissing(df.Pases) )`

This is not a good idea, since the observations are _not_ guaranteed to be matched.

We don’t have a good solution for this at the moment. Missings.jl (which is re-exported by DataFrames) provides `skipmissings`.

```julia
julia> using Missings, Statistics

julia> x = [rand() < .2 ? missing : rand() for i in 1:10];

julia> y = [rand() < .2 ? missing : rand() for i in 1:10];

julia> sx, sy = collect.(skipmissings(x, y));

julia> cor(sx, sy)
-0.32257867573052007

```

But `skipmissings` is not guaranteed to exist in the future. It’s deliberately documented as such even though Missings.jl is past 1.0.

---

_[View the full topic](https://discourse.julialang.org/t/skipmissing-no-working-in-cor-function/71293)._
