How to find top and bottom decile

You can wrap your code in backticks (```) to format it better.

gdp<-PS3$rgdppc %>%. # my object for GDPpc
    select(PS3$ccode, gdp) %>% # trying to tell R to select country code + GDPpc
    quantile(PS3$ccode, probs = seq(.1, .9, by = .1)) # getting the quantiles

Without having access to your data, we are limited in how much we can help.
FAQ: What's a reproducible example (reprex) and how do I create one?

Your pipeline does not use correct syntax, however. You are piping a vector (first line) into a function that wants a dataframe (second line) and then into another function that needs a vector (third line).

To take a complete guess, I might do something like this:

library(tidyverse)

PS3 %>%
  select(ccode, gdp) %>%
  filter(gdp >= quantile(gdp, .9, na.rm = T)) %>%
  count(ccode) %>%
  arrange(desc(ccode))
1 Like