Postgres Window Function Filter In R Example