Search code examples
rcsvsortingload

After reading .csv file in R all the data in one column... How can I separate?


I do not always have to ask a question on stackoverflow but I simply cannot find any proper solution to my problem. I am trying to read a .csv file on R and everytime it opens, all the data appears in one column. I tried everything but I cannot separate the data. I would be happy about some help <3 This is the link of the data I am trying to get: https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?end=2019&start=1990

I already tried to separate all the columns in Excel and tried several separate commands but I feel too stupid for this solution.


Solution

  • I suggest you download the data programmatically via the World Bank API instead. You will need to install the package WDI for that.

    gdp <- WDI::WDI(
      indicator = "NY.GDP.PCAP.CD",
      start = 1990,
      end = 2019
    )
    
    utils::head(gdp)
    #>                       country iso2c iso3c year NY.GDP.PCAP.CD
    #> 1 Africa Eastern and Southern    ZH   AFE 2019       1512.271
    #> 2 Africa Eastern and Southern    ZH   AFE 2018       1564.734
    #> 3 Africa Eastern and Southern    ZH   AFE 2017       1628.587
    #> 4 Africa Eastern and Southern    ZH   AFE 2016       1443.692
    #> 5 Africa Eastern and Southern    ZH   AFE 2015       1538.552
    #> 6 Africa Eastern and Southern    ZH   AFE 2014       1719.184
    

    Created on 2023-03-21 with reprex v2.0.2