OECD::OECD() function not found

Im trying to create a histogram using data from the OECD on population age coherts. I have installed the OECD package, run the library function

and typed this in, but its telling me "could not find function "OECD", please help i dont know what to do

This is my script

OECD_data <- OECD(country = "all",
indicator = c("agestructures" = "HISTPOP"),
start = 2000, end = 2020, extra = TRUE)

Have you loaded the OECD package before calling the function or you get any error message while doing so?


Hi andrescs

Thanks for your reply, i did get the following message , i quess i need to find an OECD package that is available with this version of R, or just re-install an older version of R?

Warning message:
package ‘OECD’ was built under R version 4.1.3

That is just a warning, but the OECD package doesn't seem to have an OECD() function. Can you clarify why you think it should? Maybe you are supposed to be using a different package.

Im sorry andreas, but i don't understand the language of code. As far as i can tell "HISTPOP" is code for data from the OECD on population age structures. I want to subset this data to specific country and create a histogram. So installed the OECD package, ran the library, and am now trying to get the data connected to "HISPOP"



OECD_data <- OECD(country = "all",
indicator = c("agestructures" = "HISTPOP"),
start = 2000, end = 2020, extra = TRUE

So if i type the below i can see the data, but im not sure if i can subset from the df command

"df <- get_dataset("HISTPOP", start_time = 2019, end_time = 2020)"

I don't understand why this is so hard. I have literally spent two hours trying to locate the data for "HISTPOP" so i can use it to create a histogram

Expressing anything in a language you don't know is hard but with practice, you become more fluent and things become easier.

It is not clear what you are trying to accomplish but maybe something like this?


df <- get_dataset("HISTPOP", start_time = 2019, end_time = 2020)

df %>% 
    filter(LOCATION == 'CHE', str_detect(AGE, "(\\d{1,2}_\\d{1,2})|85_OVER")) %>% 
    mutate(ObsValue = as.numeric(ObsValue),
           AGE = fct_inorder(AGE)) %>% 
    ggplot(aes(x = AGE, y = ObsValue)) + 
    geom_col() +
    facet_wrap(~Time) +
    theme(axis.text.x = element_text(angle = 45))

Created on 2022-07-13 by the reprex package (v2.0.1)

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like

Hi Andres that is basically what i was trying to do, thank you. Can i ask what is the obsValue referring to?

I wanted to refer to the figures/numbers that represent that age group? can i change the code to make it appear that way?

I can only infer from context that is the number of people in each age group for a given country and year, although, you should check the OECD web site to find out for sure.

Sorry, I don't understand what you are referring to.
You can read about data visualization from this free ebook, so you can learn how to modify the code to your liking.


Thanks Andres, ill have a look through this, unfortunately because i dont understand the lanaguage, i dont understand what im looking for which it makes it extra hard

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.